Java String Truncate truncateExtension(String name)

Here you can find the source of truncateExtension(String name)

Description

Truncates the extension of the file name.

License

Open Source License

Parameter

Parameter Description
name a parameter

Declaration

public static String truncateExtension(String name) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from ww  w  . jav  a  2  s.c  om
     * Truncates the extension of the file name. For example x.html will return x. If there is no extension,
     * the full name will be returned.
     * 
     * @param name
     * @return
     */
    public static String truncateExtension(String name) {
        return name.lastIndexOf('.') == -1 ? name : name.substring(0, name.lastIndexOf('.'));
    }
}

Related

  1. truncateCellValue(String x, int maxChars)
  2. truncateCodeStringIfNeeded(String codeString)
  3. truncateData(String data, int idLength)
  4. truncateDatabaseName(String db)
  5. truncatedStr(String s, int maxLength)
  6. truncateFileName(String agent, String s)
  7. truncateFileType(String p)
  8. truncateFirstEnd(String str)
  9. truncateHashToInt(String hash)