@Test public void replaceExtension() { Assert.assertEquals("/path/to/file.new", FileUtils.replaceExtension("/path/to/file.old", ".new")); Assert.assertEquals("/path/to/file.new", FileUtils.replaceExtension("/path/to/file", ".new")); Assert.assertEquals("/path/to/file", FileUtils.replaceExtension("/path/to/file.old", "")); Assert.assertEquals("/path/to/file", FileUtils.replaceExtension("/path/to/file.", "")); Assert.assertEquals("file.new", FileUtils.replaceExtension("file.old", ".new")); Assert.assertEquals("file.new", FileUtils.replaceExtension("file.NEW", ".new")); }
public static String replaceExtension(String path, String extension) { if (path == null) return null; int ext = path.lastIndexOf("."); return ((ext >= 0) ? path.substring(0, ext) : path) + extension; }
FileUtils { public static String replaceExtension(String path, String extension) { if (path == null) return null; int ext = path.lastIndexOf("."); return ((ext >= 0) ? path.substring(0, ext) : path) + extension; } }
FileUtils { public static String replaceExtension(String path, String extension) { if (path == null) return null; int ext = path.lastIndexOf("."); return ((ext >= 0) ? path.substring(0, ext) : path) + extension; }  }
FileUtils { public static String replaceExtension(String path, String extension) { if (path == null) return null; int ext = path.lastIndexOf("."); return ((ext >= 0) ? path.substring(0, ext) : path) + extension; }  static InputStream streamFromStringContent(String data); static String readFile(InputStream file); static String readFile(File file); static String readFile(InputStream is, byte[] buffer); static void copyStream(OutputStream outputStream, InputStream inputStream, byte[] buffer); static String internalReadFile(BufferedReader br, Object source); static void close(Closeable stream, Object source); static File tryGetCanonicalFile(String path); static File tryGetCanonicalFile(File file, File errorValue); static File tryGetCanonicalFile(File file); static String tryGetCanonicalPath(File file, String errorValue); static boolean isSymlinkDir(File directory, boolean errorValue); static String getDebugString(String prefix, File file); static String replaceExtension(String path, String extension); static String getExtension(String path); static File getDir(String path); static File createFile(String path); static File[] listFiles(File parent, final Pattern fileOrDirThatMustBeInTheRoot); static boolean isNoMedia(String path, int maxLevel); static boolean isHiddenFolder(String path); static void delete(String fileName); static void delete(String fileName, String fileExt); static void delete(File file, final String fileExt); static void copyReplace(String sourcePath, String destinationPath,
                                   boolean deleteOriginalAfterFinish, String what); static void copyReplace(File inFile, File outFile, boolean deleteOriginalAfterFinish, String what); static void copyReplace(InputStream sourceStream, File destinationFile); static void copy(InputStream is, OutputStream os); static String fixPath(String path); static File getFirstExistingDir(File root); static File getFirstNonExistingFile(File parentDir, String newFilePrefix, int number, String newFileSuffix); }
FileUtils { public static String replaceExtension(String path, String extension) { if (path == null) return null; int ext = path.lastIndexOf("."); return ((ext >= 0) ? path.substring(0, ext) : path) + extension; }  static InputStream streamFromStringContent(String data); static String readFile(InputStream file); static String readFile(File file); static String readFile(InputStream is, byte[] buffer); static void copyStream(OutputStream outputStream, InputStream inputStream, byte[] buffer); static String internalReadFile(BufferedReader br, Object source); static void close(Closeable stream, Object source); static File tryGetCanonicalFile(String path); static File tryGetCanonicalFile(File file, File errorValue); static File tryGetCanonicalFile(File file); static String tryGetCanonicalPath(File file, String errorValue); static boolean isSymlinkDir(File directory, boolean errorValue); static String getDebugString(String prefix, File file); static String replaceExtension(String path, String extension); static String getExtension(String path); static File getDir(String path); static File createFile(String path); static File[] listFiles(File parent, final Pattern fileOrDirThatMustBeInTheRoot); static boolean isNoMedia(String path, int maxLevel); static boolean isHiddenFolder(String path); static void delete(String fileName); static void delete(String fileName, String fileExt); static void delete(File file, final String fileExt); static void copyReplace(String sourcePath, String destinationPath,
                                   boolean deleteOriginalAfterFinish, String what); static void copyReplace(File inFile, File outFile, boolean deleteOriginalAfterFinish, String what); static void copyReplace(InputStream sourceStream, File destinationFile); static void copy(InputStream is, OutputStream os); static String fixPath(String path); static File getFirstExistingDir(File root); static File getFirstNonExistingFile(File parentDir, String newFilePrefix, int number, String newFileSuffix); static final String MEDIA_IGNORE_FILENAME; }