Java String Truncate truncateSentence(String input, int length)

Here you can find the source of truncateSentence(String input, int length)

Description

truncate Sentence

License

Apache License

Declaration

public static String truncateSentence(String input, int length) 

Method Source Code

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

public class Main {
    public static String truncateSentence(String input, int length) {

        int length2 = length;

        while (length2 > 0) {
            char c = (input.charAt(length));
            if (c < 'A' || c > 'z') {
                length2 = 0;/*from w w w.j  a  v  a 2s.c om*/
            } else {
                length--;
                length2--;
            }
        }
        return input.substring(0, length);
    }
}

Related

  1. truncateOnlyText(String text, int position)
  2. truncateOnSpace(String text, Integer length)
  3. truncateOrPadString(String str)
  4. truncatePrefixFromPath(String fileName)
  5. truncatePunctuation(String authority)
  6. truncateShortMessage(final String message)
  7. truncateStr(String str, int maxNumChars)
  8. truncateString(final String str, final int iMaxLength)
  9. truncateString(int length, String srcString)