新手学写文件时的一个问题
package a;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.BufferedWriter;
import
java.io.IOException;
public class leilei
{
public static void main(String args[])
{
try{
File wenjian=new File(args[0]);
File wenjian2=new File(args[1]);
if (!wenjian.exists())
{
System.out.println( "文件不存在! ");
return;
}
else if(wenjian.length()==0)
{
System.out.println( "文件长度为0! ");
return;
}
FileReader duqu=new FileReader(wenjian);
BufferedReader duqua =new BufferedReader(duqu);
FileWriter xieru=new FileWriter(args[1]);
BufferedWriter xierua =new BufferedWriter(xieru);
String zifu=duqua.readLine();
while(zifu!=null)
{
xierua.write(zifu,0,zifu.length());
System.out.println( "已写入: "+zifu);