public static void main(String[] args) {
try {
//读取需要拷贝的图片
//将读取的图片内容写入到磁盘
//创建FileInputStream对象
FileInputStream fis=new FileInputStream("D:/test/1.png");
//创建FileOutputStream对象
FileOutputStream fos=new FileOutputStream("D:/test2/1.png");
//读取文件的内容,每次读取4个字节
int len=-1; //读取的实际长度
byte[] buf=new byte[4];
//每次读取4个字节
while((len=fis.read(buf))!=-1) {
//System.out.println(Arrays.toString(buf));
//每次写入4个字节
fos.write(buf,0,len);
}
fis.close();
fos.close();
}catch(Exception ex) {
ex.printStackTrace();
}
}