62,614
社区成员
发帖
与我相关
我的任务
分享
public static void main( String[] args )
{
int b = 0;
FileReader in = null;
FileWriter out = null;
try
{
in = new FileReader( "c:\\HelloWorld.txt" );
out = new FileWriter( "c:\\HW.txt", true );
while( ( b = in.read() ) != -1 )
{
out.write( b );
System.out.write( b );
}
out.close();
in.close();
}
catch( FileNotFoundException e2 )
{
System.out.println( "aaa" );
}
catch( IOException e1 )
{
System.out.println( "bbb" );
}
System.out.println( "ccc" );
}
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class FileCopy {
public static void main(String[] args) {
BufferedReader reader = null;
BufferedWriter writer =null;
String line = "";
try {
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("H:\\zyus2.txt", true)));
reader = new BufferedReader(new FileReader("H:\\zyus1.txt"));
while((line = reader.readLine()) != null){
writer.write(line);
}
reader.close();
writer.close();
} catch (FileNotFoundException e2) {
System.out.println("找不到指定文件");
} catch (IOException e1) {
System.out.println("文件复制错误");
}
System.out.println("文件已复制");
}
}