Exception in thread "main" java.lang.NullPointerException
at Library.loadBooks(Library.java:179)
at UseLibrary.main(UseLibrary.java:105)
このエラーは私を夢中にさせます!
public void loadBooks(String s) throws IOException{
String str[] = new String[6];
String inFName = ".//" + s ;
BufferedReader input = new BufferedReader(new FileReader(inFName));
int x;
double y;
String line = "";
while(line != null){
for(int i=0; i<6; i++){
str[i] = new String();
line = input.readLine();
str = line.split("[-]");
x = Integer.parseInt(str[1]);
y = Double.parseDouble(str[2]);
Book a = new Book(str[0], x, y, str[3], str[4], str[5]);
add(a);
}
}
}
このコードの問題点は何ですか?
配列を初期化しましたが、実行されませんでした!
更新 1
save.txt
私が持っているのは
1 Don Knuth-290-23.45-The Art of Programming with Java-HG456-Engineering-5
2 A. Camp-400-13.45-An Open Life-HSA234-Philosophy-1
3 James Jones-140-12.11-Oh, Java Yeah!-SDF213-Science Fiction-2
4 J. Campbell-250-32.45-An Open Life-JH45-Science-3
5 Mary Kennedy-230-56.32-Intro to CS Using Java as the Language-USN123-Science-4