Write { public static void toFile(String path, String content, Charset charset) { Write.toFile(new File(path), content, charset); }  static File classpathResourceToTempFile(String resource); static void toFile(String path, String content, Charset charset); static void toFile(File file, String content, Charset charset); static void toFile(File file, InputStream content);  }
@Test public void testClasspathResourceToFileWithDefaultEncoding() throws IOException { File tmpFile = File.createTempFile("junit", ".txt"); Write.toFile(tmpFile, "abcåäö", Charset.defaultCharset()); String contents = Read.fromFile(tmpFile, Charset.defaultCharset()); Assert.assertEquals("abcåäö", contents); }
@Test public void testClasspathResourceToFileWithUtf8Encoding() throws IOException { File tmpFile = File.createTempFile("junit", ".txt"); Write.toFile(tmpFile, "abcåäö", StandardCharsets.UTF_8); String contents = Read.fromFile(tmpFile, StandardCharsets.UTF_8); Assert.assertEquals("abcåäö", contents); }