import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Demo3_Copy {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
demo2();
}
public static void demo2() throws FileNotFoundException, IOException {
//字符流不能拷贝纯文本的文件
FileReader fr = new FileReader("双元.jpg");
FileWriter fw = new FileWriter("copy.jpg");
int c;
while((c = fr.read()) != -1) {
fw.write(c);
}
fr.close();
fw.close();
}
} |
|