learning java FileOutputStream
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class FileOutputStreamTest { public static void main(String[] args) { try { var fis = new FileInputStream("FileInputStreamTest.java"); var fos = new FileOutputStream("output.txt"); { var buf = new byte[32]; var hasRead = 0; while ((hasRead = fis.read(buf)) > 0){ fos.write(buf, 0, hasRead); } } fis.close(); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }