안녕하세요, 저는 각 코드를 읽고 각 줄마다 문자열에 저장하는 데 어려움을 겪고 있습니다. 내 코드는 아래 텍스트 파일을로드 할 수 있지만 그것을 분할 할 수 없습니다, 나는 첫 번째 줄 나누기 얻을 수 및 그 것입니다. 나는 자바가 훌륭하지 않지만 4 줄짜리 텍스트 파일을로드하려고하고 있는데 그 코드를 파일에서 다른 문자열로 분할해야한다. 첫 번째 코드 줄을 가져올 수는 있지만 그게 전부입니다.Java : 파일을 각 행에 대한 문자열로 분할 하시겠습니까?
Load.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
int returnValue = fileChooser.showOpenDialog(null);
if (returnValue == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
String nextLine = reader.readLine();
if (nextLine != null && nextLine.startsWith("Title:")) {
title = nextLine.substring(6);
panel.showText(title);
nextLine = reader.readLine();
}
reader.close();
} catch (IOException e1) {
System.err.println("Error while reading the file");
}
}
}
});
가 왜 꽵 두 번 확인합니다! = 여기서 코드 자체보다 더 while 루프를 추가하는 강조 – Christian
널, 내가하는 방법으로이 문제를 유출 한 것입니다있는이해야 아마도 – dave