import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; //文件的复制 public class Demo03Copy { public static void main(String[] args) throws IOException { FileInputStream fis=new FileInputStream("F:\\basic\\untitled13\\src\\it\\cast\\day15\\demo01\\1.txt"); FileOutputStream fos=new FileOutputStream("F:\\basic\\untitled13\\src\\it\\cast\\day15\\demo01\\3.txt"); byte[] bytes1=new byte[1024]; int len=0; while ((len=fis.read(bytes1))!=-1){ //System.out.println(new String(bytes1,0,len));//读取有效的几个 fos.write(bytes1,0,len); } } }
原文:https://www.cnblogs.com/cy2268540857/p/13773971.html