쉼표로 구분 된 CSV 파일이 있고 두 번째 줄에서 읽을 코드가 있습니다. 그러나 다음과 같은 오류가 발생합니다. 스레드 "AWT-EventQueue-0"의 예외 java.lang.OutOfMemoryError : Java 힙 공간
이것은 내 코드입니다.
public static List<String> readCSV(String path){
BufferedReader br = null;
String[] cd = null;
String line ="";
String split=",";
List<String> list = new ArrayList<String>();
try {
br=new BufferedReader(new FileReader(path));
while ((line = br.readLine()) != null) {
boolean firstLine = true;
while (line != null && line.startsWith("child's Last Name")) {
if (firstLine) {
firstLine = false;
continue;
} else {
list.add(line);
}
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return list;
}
이 코드로 어떻게 고칠 수 있나요 ..
미리 감사드립니다!
시험
br=new BufferedReader(new FileReader(path));
boolean firstLine = true;
while ((line = br.readLine()) != null) {
if (line.startsWith("child's Last Name")) {
if (firstLine) {
firstLine = false;
continue;
}
list.add(line);
}
}
두 개의 while 루프가 필요하지 않습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다