Java String Shorten shorten(String msg, int front, String join, int end)

Here you can find the source of shorten(String msg, int front, String join, int end)

Description

General short string helper.

License

Open Source License

Parameter

Parameter Description
msg a parameter
front a parameter
join a parameter
end a parameter

Declaration

public static String shorten(String msg, int front, String join, int end) 

Method Source Code

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

public class Main {
    /**/*from w w w  .j a  v a 2  s.c o m*/
     * General short string helper. Print max front chars from the beginning,
     *  the join string and max end chars from the end.
     * @param msg
     * @param front
     * @param join
     * @param end
     * @return
     */
    public static String shorten(String msg, int front, String join, int end) {
        if (msg.length() <= (front + join.length() + end))
            return msg;
        return msg.substring(0, front) + join + msg.substring(msg.length() - end);
    }
}

Related

  1. shorten(String in)
  2. shorten(String input)
  3. shorten(String input, int length, boolean wholeWord)
  4. shorten(String label, int maxLength)
  5. shorten(String line)
  6. shorten(String name, int max)
  7. shorten(String nameForUI, int maxLen)
  8. shorten(String pkg, boolean shorten)
  9. shorten(String s)