Java String Truncate trunc(String in, int len)

Here you can find the source of trunc(String in, int len)

Description

This method is used to truncate a string to a specific length.

License

EUPL

Parameter

Parameter Description
in the PDF selected file
len the PDF selected file

Return

the InputStream of the XML file

Declaration

public static String trunc(String in, int len) 

Method Source Code

//package com.java2s;
/*/*w ww  .jav a2s  .c  o m*/
 * Copyright European Union 2002-2010
 *
 *
 * Licensed under the EUPL, Version 1.1 or ? as soon they 
 * will be approved by the European Commission - subsequent  
 * versions of the EUPL (the "Licence"); 
 * You may not use this work except in compliance with the 
 * Licence. 
 * You may obtain a copy of the Licence at: 
 *
 * http://ec.europa.eu/idabc/eupl.html
 *
 *  
 * Unless required by applicable law or agreed to in 
 * writing, software distributed under the Licence is 
 * distributed on an "AS IS" basis, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
 * express or implied. 
 * See the Licence for the specific language governing 
 * permissions and limitations under the Licence. 
 *
 */

public class Main {
    /**
     * This method is used to truncate a string to a specific length.
     * @param in the PDF selected file
     * @param len the PDF selected file
     * @return the InputStream of the XML file
     */
    public static String trunc(String in, int len) {
        if (in != null && in.length() > len)
            return in.substring(0, len);
        return in;
    }
}

Related

  1. trunc(String s, int length)
  2. trunc(String s1, int length)
  3. trunc(String str, int length)
  4. trunc(String string, int length)