그래서 DVD의 카탈로그 파일을 읽고 배열 목록에 데이터를로드해야합니다. 파일 입력 과정을 거쳤지만 DVD를 올바르게 입력하는 방법을 알지 못합니다.txt 파일에서 배열 목록으로 데이터로드
ArrayList<DVD> arraylist = new ArrayList<>();
public void loadData(String fileName){
try{
Scanner input = new Scanner(new FileReader(fileName));
System.out.println("file read");
while (input.hasNext()){
arraylist.add(input);
input.close(); }
} catch(FileNotFoundException E) {
System.err.print(fileName + " Not Found");
System.exit(1);
}
}
제목, 카테고리, 실행 시간, 연도 및 가격을 포함하는 텍스트 파일에 포함 된 내용입니다.
Adam
Documentary
78 minutes
2012
7.99
Choo Choo
Documentary
60 minutes
2006
11.99
Good Morning America
Documentary
80 minutes
2010
9.99
Life is Beautiful
Drama
125 minutes
1999
15.99
Morning Bird
Comic
150 minutes
2008
17.99
Mystic River
Mystery
130 minutes
2002
24.99