一、使用字节流复制文本文件/图片
private static void method16() throws IOException { //1.创建字节输入流(写入数据) FileInputStream is = new FileInputStream("D:\\23.png"); //2.创建字节输出流(写出数据) FileOutputStream os = new FileOutputStream("E:\\k.jpg"); byte[] bys = new byte[1024]; int len; //遍历读取数据 while ((len = is.read(bys )) != -1) { //写数据 os.write(bys , 0, len); os.flush(); } //释放资源 is.close(); os.close(); }