@Test public void testGetSafeFilename() { assertEquals("my-image.png", FileUtils.getSafeFilename("my-image.png")); assertEquals("_", FileUtils.getSafeFilename("..")); assertEquals("tmp___2349_876398___foo.png", FileUtils.getSafeFilename("tmp/../2349:876398/*/foo.png")); assertEquals("_tmp___2349_876398___foo.png", FileUtils.getSafeFilename("\\tmp\\..\\2349:876398\\*\\foo.png")); }
public static String getSafeFilename(String filename) { return filename.replaceAll("(\\\\)|(\\/)|(\\:)|(\\*)|(\\.\\.)", "_"); }
FileUtils { public static String getSafeFilename(String filename) { return filename.replaceAll("(\\\\)|(\\/)|(\\:)|(\\*)|(\\.\\.)", "_"); } }
FileUtils { public static String getSafeFilename(String filename) { return filename.replaceAll("(\\\\)|(\\/)|(\\:)|(\\*)|(\\.\\.)", "_"); } private  FileUtils(); }
FileUtils { public static String getSafeFilename(String filename) { return filename.replaceAll("(\\\\)|(\\/)|(\\:)|(\\*)|(\\.\\.)", "_"); } private  FileUtils(); static void copy(File src, File dst); static void copy(File[] src, File dst); @Deprecated static void copyFile(File src, File dst); @Deprecated static void copyTree(File src, File dst); @Deprecated static void copyTree(File src, File dst, PathFilter filter); static void copyTree(File src, File dst, Path prefix, PathFilter filter); static String getFilePathFromUrl(URL url); static File getFileFromURL(URL url); static String getParentPath(String path); static String getFileName(String path); static String getFileExtension(String path); static String getFileNameNoExt(String path); static String getResourcePathFromContext(String resource); static File getResourceFileFromContext(String resource); static File[] findFiles(File root, String pattern, boolean recurse); static void collectFiles(File root, FileNamePattern pattern, List<File> result); static void collectFiles(File root, List<File> result); static File urlToFile(String url); static File urlToFile(URL url); static boolean areFilesContentEquals(String expected, String source); static String getSafeFilename(String filename); }
FileUtils { public static String getSafeFilename(String filename) { return filename.replaceAll("(\\\\)|(\\/)|(\\:)|(\\*)|(\\.\\.)", "_"); } private  FileUtils(); static void copy(File src, File dst); static void copy(File[] src, File dst); @Deprecated static void copyFile(File src, File dst); @Deprecated static void copyTree(File src, File dst); @Deprecated static void copyTree(File src, File dst, PathFilter filter); static void copyTree(File src, File dst, Path prefix, PathFilter filter); static String getFilePathFromUrl(URL url); static File getFileFromURL(URL url); static String getParentPath(String path); static String getFileName(String path); static String getFileExtension(String path); static String getFileNameNoExt(String path); static String getResourcePathFromContext(String resource); static File getResourceFileFromContext(String resource); static File[] findFiles(File root, String pattern, boolean recurse); static void collectFiles(File root, FileNamePattern pattern, List<File> result); static void collectFiles(File root, List<File> result); static File urlToFile(String url); static File urlToFile(URL url); static boolean areFilesContentEquals(String expected, String source); static String getSafeFilename(String filename);  }