源代码如下
import java.io.*;
public class Test4Demo {
public static void main(String[] args) {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(new File("d:\\ff\\Water.jpg"));
fos = new FileOutputStream(new File("d:\\ff1\\Water.jpg"));
byte[] b = new byte[1024];
int n = 0;
while((n = fis.read(b)) != -1)
{
String s = new String(b,0,n);
fos.write(s.getBytes());
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}finally{
try {
fis.close();
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
能将图片复制到相应的位置 问题是用windows自带的图片查看器没法打开预览 很郁闷 这事怎么回事?我注意到新复制的文件大小跟源文件不一样了 小了一些 这事怎么回事?