Java String Truncate truncate(String str, String prefix, String suffix)

Here you can find the source of truncate(String str, String prefix, String suffix)

Description

truncate

License

Open Source License

Declaration

private static String truncate(String str, String prefix, String suffix) 

Method Source Code

//package com.java2s;

public class Main {
    private static String truncate(String str, String prefix, String suffix) {
        if (str.startsWith(prefix) && str.endsWith(suffix))
            return str.substring(prefix.length(), str.length() - suffix.length());

        return str;
    }//ww  w  . j  a v  a  2 s. co m
}

Related

  1. truncate(String str, int maxSize)
  2. truncate(String str, int maxSize)
  3. truncate(String str, int n)
  4. truncate(String str, int size, boolean useEllipsis)
  5. truncate(String str, int start, int end)
  6. truncate(String string, final int length)
  7. truncate(String string, int length)
  8. truncate(String string, int maxLength, boolean atBeginning, String ellipse)
  9. truncate(String string, int maxSize)