import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Demo {
public static void main(String[] args) throws IOException {
// 1. 创建流对象
FileInputStream fis = new FileInputStream("D:\\maxresdefault.jpg");
FileOutputStream fos = new FileOutputStream("test_copy.jpg");
// 2. 读写数据
// 定义数组
byte[] b = new byte[1024];
// 定义长度
int len;
// 循环读取
while ((len = fis.read(b)) != -1){
//写出数据
fos.write(b, 0, len);
}
// 3. 关闭资源
fos.close();
fis.close();
}
}