package JAVA;import java.io.*;public class TextFileReaderLine{ String filename; FileReader fw; public TextFileReaderLine(String f) { filename = f; try { fw = new FileReader(new File(f)); } catch(IOException e) {} } public void readLine() { char ch = '\u0000'; try { while(ch != -1) { ch = (char)fw.read(); System.out.print(ch); } } catch(IOException e) { System.out.print("Error!"); } }public static void main(String args[]){ TextFileReaderLine frs = new TextFileReaderLine("text1.txt"); frs.readLine();}}提示的错误:Exception in thread "main" java.lang.NullPointerException at JAVA.TextFileReaderLine.readLine(TextFileReaderLine.java:25) at JAVA.TextFileReaderLine.main(TextFileReaderLine.java:37)就是Read()函数与ReadLine()函数的调用问题,其实质是未实例化的调用,但是怎么修改呢?还是因为其他的错误呢??O(∩_∩)O谢谢!
添加回答
举报
0/150
提交
取消