import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; //文件复制 一读一写 public class Demo02OutputStream { public static void main(String[] args) throws IOException { FileInputStream fis = new FileInputStream("D:\\a.txt"); FileOutputStream fos = new FileOutputStream("C:\\a.txt"); //方法一 int len = 0; while ((len=fis.read()) != -1){ fos.write(len); } //fos.close(); //fis.close(); //方法二 byte[] bytes = new byte[1024]; int len1 = 0; while ((len1=fis.read()) != -1){ fos.write(len); } fos.close(); fis.close(); } }
JAVA-字节流-基础
于 2022-04-13 21:23:06 首次发布