何がうまくいかなかったのかはわかりませんが、印刷では、txtファイルから完全に情報が得られるのは2回目だけです。初めて、txt ファイルにある最初の行のみが出力されます。誰かが私の間違いを指摘してくれることを願っています。
これが私のコードです:
public static void main(String[]args) {
try {
FileReader fileReader = new FileReader("data_file/Contact.txt");
BufferedReader in = new BufferedReader(fileReader);
String currentContact = in.readLine();
StringBuilder sb = new StringBuilder();
while(currentContact != null) {
StringBuilder current = sb.append(currentContact);
current.append(System.getProperty("line.separator"));
JOptionPane.showMessageDialog(null, "Contact : \n" + current);
// System.out.println("Contact:" + currentContact);
currentContact = in.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
}