GroupDocsGists
10/19/2017 - 11:24 AM

GetFileNameWithoutExtension.java

// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
/**
 * This method gets extension of file
 * 
 * @param fileName
 *            name of the file
 */
public static String getFileNameWithoutExtension(String fileName) {
	try {

		return fileName.replaceFirst("[.][^.]+$", "");

	} catch (Exception exp) {
		System.out.println("Exception: " + exp.getMessage());
		exp.printStackTrace();
		return null;
	}

}