Java String Truncate truncate(String message)

Here you can find the source of truncate(String message)

Description

truncate

License

Apache License

Declaration

public static String truncate(String message) 

Method Source Code

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

public class Main {
    public static String truncate(String message) {
        if (message.lastIndexOf(".") < 500 && message.lastIndexOf(".") != -1) {
            return message.substring(0, message.lastIndexOf("."));
        }//w w  w  .j  a  v a 2  s  . c o m
        message = message.substring(0, 495);
        //this one can cut quite a lot of stuff..
        if (message.lastIndexOf(".") < 500 && message.lastIndexOf(".") != -1) {
            return message.substring(0, message.lastIndexOf("."));
        }
        return message + "...";
    }
}

Related

  1. truncate(Object truncateMe, int maxLength, String suffix)
  2. truncate(String eval, String suffix, int targetLength)
  3. truncate(String input, int maxLength)
  4. truncate(String input, int maxLength)
  5. truncate(String input, int size)
  6. truncate(String message, int length, boolean includeCount)
  7. truncate(String message, String substring)
  8. truncate(String original, int number)
  9. truncate(String original, String ellipsis, int maxLength)