0
我试图在JOptionPane窗口中显示搜索结果,以便在文本文件中找到某个搜索结果时,在文本文件中打印出该行。但它在单独的窗口中打印出每一行,是否有任何方法可以将它们全部打印在同一窗口中?JOptionPane显示循环
public static void DisplayGrades() throws IOException
{
String line;
String stringToSearch = JOptionPane.showInputDialog(null, "Enter your student ID");
BufferedReader in = new BufferedReader(new FileReader("StudentResults.csv"));
line = in.readLine();
while (line != null)
{
if (line.startsWith(stringToSearch))
{
JOptionPane.showMessageDialog(null, line);
}
line = in.readLine();
}
in.close();
}