@Test public void testFileContentEquals() { assertTrue(FileUtils.areFilesContentEquals(null, null)); String fileContent1 = "Hello\nWorld"; String fileContent1b = "Hello\nWorld"; String fileContent2 = "Hello\r\nWorld"; String fileContent3 = "Hello \nWorld"; assertTrue(FileUtils.areFilesContentEquals(fileContent1, fileContent2)); assertTrue(FileUtils.areFilesContentEquals(fileContent2, fileContent1)); assertTrue(FileUtils.areFilesContentEquals(fileContent1, fileContent1b)); assertFalse(FileUtils.areFilesContentEquals(fileContent1, null)); assertFalse(FileUtils.areFilesContentEquals(fileContent2, fileContent3)); }
public static boolean areFilesContentEquals(String expected, String source) { if (expected == source) { return true; } if (expected == null || source == null) { return false; } if (expected.length() != source.length()) { return expected.replace("\r\n", "\n").equals(source.replace("\r\n", "\n")); } else { return expected.equals(source); } }
FileUtils { public static boolean areFilesContentEquals(String expected, String source) { if (expected == source) { return true; } if (expected == null || source == null) { return false; } if (expected.length() != source.length()) { return expected.replace("\r\n", "\n").equals(source.replace("\r\n", "\n")); } else { return expected.equals(source); } } }
FileUtils { public static boolean areFilesContentEquals(String expected, String source) { if (expected == source) { return true; } if (expected == null || source == null) { return false; } if (expected.length() != source.length()) { return expected.replace("\r\n", "\n").equals(source.replace("\r\n", "\n")); } else { return expected.equals(source); } } private  FileUtils(); }
FileUtils { public static boolean areFilesContentEquals(String expected, String source) { if (expected == source) { return true; } if (expected == null || source == null) { return false; } if (expected.length() != source.length()) { return expected.replace("\r\n", "\n").equals(source.replace("\r\n", "\n")); } else { return expected.equals(source); } } 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 boolean areFilesContentEquals(String expected, String source) { if (expected == source) { return true; } if (expected == null || source == null) { return false; } if (expected.length() != source.length()) { return expected.replace("\r\n", "\n").equals(source.replace("\r\n", "\n")); } else { return expected.equals(source); } } 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);  }