FileUtils { public static Charset getCharset(String path) { if (path.contains(FileUtils.FILE_PATH_CHARSET_PARAMETER)) { return Charset.forName(path.substring(path.indexOf(FileUtils.FILE_PATH_CHARSET_PARAMETER) + FileUtils.FILE_PATH_CHARSET_PARAMETER.length())); } else { return FileUtils.getDefaultCharset(); } } private  FileUtils(); static void setSimulationMode(boolean mode); static String readToString(Resource resource); static String readToString(InputStream inputStream); static String readToString(File file); static String readToString(Resource resource, Charset charset); static String readToString(InputStream inputStream, Charset charset); static void writeToFile(InputStream inputStream, File file); static void writeToFile(String content, File file); static void writeToFile(String content, File file, Charset charset); static List<File> findFiles(final String startDir, final Set<String> fileNamePatterns); static Resource getFileResource(String filePath, TestContext context); static Resource getFileResource(String filePath); static Charset getDefaultCharset(); static Charset getCharset(String path); static String getFileExtension(String path); final static String FILE_PATH_CHARSET_PARAMETER; }
@Test public void testGetCharset() throws Exception { Assert.assertEquals(FileUtils.getCharset("/path/to/some/file.txt").displayName(), CitrusSettings.CITRUS_FILE_ENCODING); Assert.assertEquals(FileUtils.getCharset("/path/to/some/file.txt" + FileUtils.FILE_PATH_CHARSET_PARAMETER + "ISO-8859-1"), Charset.forName("ISO-8859-1")); }