import java.awt.*;
import java.io.*;
public class a{
public static void main(String args[]) throws IOException{
Frame fillTextArea=new Frame("TextArea Demo");
TextArea printFile=new TextArea(30,60);
fillTextArea.add(printFile);
String oneLine;
BufferedReader buf = new BufferedReader(new FileReader("Book.java"));
while((oneLine=buf.readLine())!=null)
printFile.append(oneLine+'\n');
buf.close();
fillTextArea.pack();
fillTextArea.setVisible(true);
}
}
下面是异常--------------- 我打开的文件和我写的文件的路径相同
Exception in thread "main" java.io.FileNotFoundException: Book.java (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at a.main(a.java:13)