List of utility methods to do Path File Extention nio
String | getFileExtension(final Path file) get File Extension if (file == null) { return ""; } else { final String fileName = file.toString(); return getFileExtension(fileName == null ? "" : fileName); |
String | getFileExtension(final Path path) Return the extension of the file. Strip all the parent folders and the name of the file to return just the file extension. Objects.requireNonNull(path); if (Files.isDirectory(path)) { throw new IllegalArgumentException("Cannot get extension of a directory"); final String filename = path.getFileName().toString(); final int extensionSeparatorIndex = filename.lastIndexOf(FILE_EXTENSION_SEPARATOR); if (extensionSeparatorIndex <= 0) { return ""; ... |
Optional | getFileExtension(Path file) Returns the extension of a file or Optional.empty() if the file does not have one (no . return getFileExtension(file.toString());
|
String | getFileextension(Path path) Returns the fileextension of the file represented by the given path Example: outputdir is /a/b and path represents /a/b/c/d/e.txt.tmp returns txt.tmp String fileextension = null; String fullFileName = (path.getFileName() == null) ? "" : path.getFileName().toString(); if (fullFileName.contains(".")) { fileextension = fullFileName.substring(fullFileName.indexOf(".") + 1); return fileextension; |
String | getFileExtension(Path path) get File Extension String fileNameWithExt = path.getName(path.getNameCount() - 1).toString(); int index = fileNameWithExt.lastIndexOf('.'); if (index != -1) return fileNameWithExt.substring(index + 1); else return null; |
String | getFileExtension(Path path) Gets the file extension of the given path. String ext = path.getFileName().toString(); int index = ext.lastIndexOf('.'); if (index <= 0) { return ""; } else { return ext.substring(index, ext.length()); |
String | getFileExtension(Path path) Herausfiltern einer Dateiendung String fileName = path.getFileName().toString(); return fileName.lastIndexOf('.') == -1 ? "" : fileName.substring(fileName.lastIndexOf('.')); |
String | getFileExtension(Path path) get File Extension String fname = path.getFileName().toString(); return fname.substring(fname.lastIndexOf('.') + 1); |
String | getFileNameNoExtensionFromPath(String modulePath) Gets the name of the module, minus the windows file extension if on Windows Path path = Paths.get(modulePath); String fileNameNoPath = path.getFileName().toString(); String fileNameNoExtension = fileNameNoPath; int extIdx = 0; if ((extIdx = fileNameNoPath.lastIndexOf(".")) != -1) { fileNameNoExtension = fileNameNoPath.substring(0, extIdx + 1); return fileNameNoExtension; ... |
String | getFilenameWithoutExtension(Path file) Gets the filename without the extension return getFilenameWithoutExtension(file.getFileName().toString());
|