Java String Truncate trunc(String txt, int size)

Here you can find the source of trunc(String txt, int size)

Description

trunc

License

Open Source License

Declaration

public static String trunc(String txt, int size) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String trunc(String txt, int size) {
        if (txt == null)
            return txt;
        else if (txt.length() > size) {
            return txt.substring(0, size - 1);
        } else {/*from w w w.j  a  va2  s  . c  o  m*/
            return txt;
        }
    }
}

Related

  1. trunc(String in, int len)
  2. trunc(String s, int length)
  3. trunc(String s1, int length)
  4. trunc(String str, int length)
  5. trunc(String string, int length)
  6. trunc(String value, int len)
  7. truncate(final String description)
  8. truncate(final String in, final int maxLen)
  9. truncate(final String originalString, final int maxChars)