代码实现图片的复制
知识点:IO流
public void info() throws IOException {
File file1 = new File("d:\\tmp", "copy.png");
File file2 = new File("d:\\picture", "copy.png");
FileInputStream fileInputStream = new FileInputStream(file1);
FileOutputStream fileOutputStream = new FileOutputStream(file2,true);
if (file1.exists()) {
byte buf[] = new byte[8];
int readLen = 0;
while ((readLen = fileInputStream.read(buf)) != -1) {
fileOutputStream.write(buf);
}
System.out.println("复制完毕");
} else {
System.out.println("文件不存在");
}
}