Java examples for File Path IO:File Stream
Copying from an Input Stream to a File
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; public class Main { public static void main(String[] args) throws Exception { Path copy_from = Paths.get("C:/folder1/folder0/folder9", "draw_template.txt"); Path copy_to = Paths.get("C:/folder1/folder0/folder8", "draw_template.txt"); try (InputStream is = new FileInputStream(copy_from.toFile())) { Files.copy(is, copy_to, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { System.err.println(e);/*w ww. j a va2 s .co m*/ } } }