Java String Shorten shorten(String s)

Here you can find the source of shorten(String s)

Description

shorten

License

Apache License

Declaration

public static String shorten(String s) 

Method Source Code

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

public class Main {
    public static String shorten(String s) {
        return shorten(s, 20);
    }/*  ww  w .j  a  va2 s . c om*/

    public static String shorten(String s, int length) {
        return shorten(s, length, "..");
    }

    public static String shorten(String s, String suffix) {
        return shorten(s, 20, suffix);
    }

    public static String shorten(String s, int length, String suffix) {
        if (s == null || suffix == null) {
            return null;
        }

        if (s.length() > length) {
            s = s.substring(0, length) + suffix;
        }

        return s;
    }
}

Related

  1. shorten(String name, int max)
  2. shorten(String nameForUI, int maxLen)
  3. shorten(String pkg, boolean shorten)
  4. shorten(String s)
  5. shorten(String s)
  6. shorten(String s)
  7. shorten(String s, int len)
  8. shorten(String s, int length)
  9. shorten(String s, int length, String suffix)