我的想法:可能是FileReader和FileWriter只能处理字符流,即纯文本文件;而图形好像是
二进制文件;所以不能实现图形复制。如果是这样,哪有没有二进制的图形文件呢?
package inputandoutput;
import java.io.*;
public class copyphotoFileReaderandFileWriter
{
public static void main(String[] args) throws IOException
{
FileReader fi=new FileReader("e:\\workspace\\photo.jpg");
FileWriter fo=new FileWriter("e:\\workspace\\copyphoto.jpg");
char ch[]=new char[10000];
fi.read(ch);//将图形文件读入ch字符数组
fo.write(ch);//将ch字符数组数据写入新文件copyphoto
System.out.println("图形文件已被复制且更名");
fi.close();
fo.close();
}
}