Java String Shorten shorten(String string, boolean isPrefix)

Here you can find the source of shorten(String string, boolean isPrefix)

Description

shorten

License

Open Source License

Declaration

protected static String shorten(String string, boolean isPrefix) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

public class Main {
    protected static String shorten(String string, boolean isPrefix) {
        if (string.length() > 10)
            if (isPrefix)
                return "..." + string.substring(string.length() - 10);
            else// www .  java  2  s.c  o m
                return string.substring(0, 10) + "...";
        else
            return string;
    }
}

Related

  1. shorten(String s, int max)
  2. shorten(String s, int maxLength)
  3. shorten(String script, int length)
  4. shorten(String str, int length)
  5. shorten(String str, int length)
  6. shorten(String string, int size)
  7. shorten(String string, int upTo)
  8. shorten(String text, int max)
  9. shorten(String text, int size, int mode)