Here you can find the source of getFileNameWithoutExtension(File file)
Parameter | Description |
---|---|
file | The File in question |
public static String getFileNameWithoutExtension(File file)
//package com.java2s; import java.io.File; public class Main { /**//from ww w .j a v a2 s. c om * Get the short name portion of a filename not including the extension. * @param file The File in question * @return The name part of a file name excluding the extension */ public static String getFileNameWithoutExtension(File file) { String fileName = file.getName(); int i = fileName.lastIndexOf('.'); if (i > 0 && i < fileName.length() - 1) { return fileName.substring(0, i); } else { return fileName; } } }