Here you can find the source of writeDataFile(final String resourceName, final Path sourcePath)
public static void writeDataFile(final String resourceName, final Path sourcePath) throws IOException, URISyntaxException
//package com.java2s; //License from project: Apache License import java.io.FileOutputStream; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; import static java.lang.Thread.currentThread; import static java.nio.file.Files.copy; public class Main { public static void writeDataFile(final String resourceName, final Path sourcePath) throws IOException, URISyntaxException { copy(Paths.get(currentThread().getContextClassLoader() .getResource(resourceName).toURI()), new FileOutputStream( sourcePath.toFile(), false)); }/* w w w . j ava 2 s .co m*/ }