Java Files create OutputStream for new file
import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; public class Main { public static void main(String[] args) { Path file = Paths.get("Main.java"); Path newFile = Paths.get("MainUsers.txt"); try (InputStream in = Files.newInputStream(file); OutputStream out = Files.newOutputStream(newFile, StandardOpenOption.CREATE)) { int data = in.read(); while (data != -1) { out.write(data);/* w w w . j a v a2 s . c om*/ data = in.read(); } } catch (Exception e) { e.printStackTrace(); } } }