import
java.io.File;
import
java.io.FileInputStream;
import
java.io.FileOutputStream;
import
java.io.IOException;
public
class
demo6 {
/**
* 把一张图片拷贝到指定的位置
*
*/
public
static
void
main(String[] args)
throws
IOException {
File file =
new
File(
"C:\Users\PC-LUO\Desktop\新建文件夹\98.jpg"
);
File file2 =
new
File(
"C:\Users\PC-LUO\Desktop\4.jpg"
);
image(file, file2);
}
public
static
void
image(File file , File file2)
throws
IOException{
FileInputStream inputStream =
new
FileInputStream(file);
FileOutputStream outputStream =
new
FileOutputStream(file2);
byte
[] b =
new
byte
[
1024
];
while
(inputStream.read(b) != -
1
) {
outputStream.write(b);
}
outputStream.close();
inputStream.close();
}
}