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();
}