谢谢你解决我的第一个问题,我现在收到一个新的错误
import java.io.*;
import javax.swing.*;
public class FileBrowser {
public static void main(String[] args) throws IOException {
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
File file = chooser.getSelectedFile();
String filename = file.getName();
System.out.println("You have selected: " + filename);
FileReader fr = new FileReader("filename");
BufferedReader br = new BufferedReader(fr);
String s;
while((s = br.readLine()) != null) {
System.out.println(s);
}
fr.close();
}
}
Run Code Online (Sandbox Code Playgroud)
错误:
java.io.FileNotFoundException: filename (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97) …Run Code Online (Sandbox Code Playgroud) java ×1