Java String Truncate truncateString(String s, int numChars)

Here you can find the source of truncateString(String s, int numChars)

Description

truncate String

License

BSD License

Declaration

public static String truncateString(String s, int numChars) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

public class Main {
    public static String truncateString(String s, int numChars) {
        if (s != null && s.length() > numChars) {
            s = s.substring(0, numChars);
        }//from  ww  w.  ja  v  a 2s.  c  om
        return s;
    }
}

Related

  1. truncateString(int length, String srcString)
  2. truncateString(String description, int length)
  3. truncateString(String errCode, int length, boolean isRight)
  4. truncateString(String inStr, int maxValue)
  5. truncateString(String s)
  6. truncateString(String source, int prefixLength, int totalLength)
  7. truncateString(String source, String suffix)
  8. truncateString(String str, int length)
  9. truncateString(String str, int length, String suffix)