我查了下APIBufferedWriter类是没有String Write(String s)这个方法的,但是为什么我对文件里输出时用字符串做参数能够正确输出呢?
代码如下:
import java.io.*;
public class Faq
{
public static void main(String[] args)
{
BufferedReader br=null;
BufferedWriter bw=null;
try
{

br=new BufferedReader (new FileReader("f:\\java\\hao.txt"));
bw=new BufferedWriter(new FileWriter("f:\\java\\iver99.txt"));
String s=null;
while((s=br.readLine()) !=null)
{
System.out.print(s);
bw.write(s);                 //这里  s是个字符串
}
System.out.println();
}
catch(FileNotFoundException e)
{
System.out.println("file not found");
e.printStackTrace();
}
catch(IOException e)
{
System.out.println("file error1");
e.printStackTrace();
}
finally
{
try
{
br.close();
bw.close();

}
catch(IOException e)
{
System.out.println("file error2");
e.printStackTrace();

}
}
}
}

运行完后我打开iver99。txt发现能够正确写入,为什么呢?