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 基础 文件复制
猜你喜欢
转载自blog.csdn.net/weixin_41918727/article/details/105235310
今日推荐
周排行