新手空指针错误,一直没找到有关问题出在那里!多谢
新手求助:空指针异常,一直没找到问题出在那里!谢谢
提示:空指针异常。
------解决方案--------------------
while((line=bufr.readLine())!=null);
看看你的while,后面多了个什么
发现没?

------解决方案--------------------
提示:空指针异常。
import java.io.*;
class CopyTextByBuf
{
public static void main(String[] args)
{
BufferedReader bufr=null;
BufferedWriter bufw=null;
try
{
bufr=new BufferedReader(new FileReader("BufferedWriterDemo.java"));
bufw=new BufferedWriter(new FileWriter("BufWriter_Copy.txt"));
String line=null;
while((line=bufr.readLine())!=null);
{
bufw.write(line);
bufw.newLine();
bufw.flush();
}
}
catch (IOException e)
{
throw new RuntimeException("读写失败");
}
finally
{
try
{
if(bufr!=null)
bufr.close();
}
catch (IOException e)
{
throw new RuntimeException("读取关闭失败");
}
try
{
if(bufw!=null)
bufw.close();
}
catch (IOException e)
{
throw new RuntimeException("写入关闭失败");
}
}
}
}
------解决方案--------------------
while((line=bufr.readLine())!=null);
看看你的while,后面多了个什么
发现没?
------解决方案--------------------