package demo5; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.Arrays; public class demo6 { public static void main(String[] args) throws IOException { //读取文件 FileInputStream fis = new FileInputStream("/Users/wanggang/Desktop/java/src/demo5/1.jpg"); FileOutputStream fos = new FileOutputStream("/Users/wanggang/Desktop/java/src/demo5/2.jpg"); // int len = 0; // while ((len=fis.read())!=-1){ // fos.write(len); // // } // fos.close(); // fis.close(); byte[] bytes = new byte[1024]; int len = 0; while ((len=fis.read())!=-1){ fos.write(bytes,0,len); } } }
Java 基础 文件复制
最新推荐文章于 2023-06-30 09:23:14 发布