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(); } } }
原文地址:https://www.cnblogs.com/lianghong881018/p/11302425.html
时间: 2024-10-17 16:21:51