package filestream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class ByteStreamTester { public static void main(String [] args) { FileInputStream in = null; FileOutputStream out = null; String path = "E:\\java\\"; try { in = new FileInputStream(path+"IOFile.txt"); out = new FileOutputStream(path+"IOFile_copy.txt"); int c; while ((c=in.read())!=-1) { out.write(c); } } catch(FileNotFoundException e) { e.printStackTrace(); } catch(IOException e) { e.printStackTrace(); } finally { try { if(in!=null) in.close(); if(out!=null) out.close(); } catch(IOException e) { e.printStackTrace(); } } } }
时间: 2024-10-19 08:00:29