Write { public static File classpathResourceToTempFile(String resource) { try { File destination = File.createTempFile(new File(resource).getName() + ".", ""); destination.deleteOnExit(); InputStream in = Write.class.getResourceAsStream(resource); Write.toFile(destination, in); in.close(); return destination; } catch (IOException io) { throw new RuntimeException(io); } }  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 testClasspathResourceToFile() { File d = Write.classpathResourceToTempFile("/joist/util/WriteTest.txt"); System.out.println(d); String contents = Read.fromFile(d, Charset.defaultCharset()); Assert.assertEquals("foo", contents); }