转换流复制TXT文件,代码如下,但是一运行就报
java.lang.NullPointerException
不知道为什么,求解答
import java.io.*;
class FileCopyDemo1
{
public static void main(String[] args) throws IOException
{
//System.out.println("Hello World!");
FileInputStream fis = new FileInputStream("D:/abc.txt");//创建字节输入流
InputStreamReader isr = new InputStreamReader(fis);//将字节输入流转化为字符输入流
BufferedReader br = new BufferedReader(isr);//对字符输出流进行包装
FileOutputStream fos = new FileOutputStream("D:/123.txt");//创建字节输出流
OutputStreamWriter osw = new OutputStreamWriter(fos);//将字节输出流转化为字符输出流
BufferedWriter bw = new BufferedWriter(osw);//将字符输出流进行包装
String line;
while ((line=br.readLine())!=null);
{
bw.write(line);
bw.newLine();
}
br.close();
bw.close();
}
}
|
|