-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sign.java
66 lines (63 loc) · 2.59 KB
/
Sign.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package project;
import java.io.*;
import static project.CustInfo.*;
public class Sign {
/**
* To get the information about books from databases;
* Pre: null;
* Post: the information of books will be got from databases.
*/
public void setArray(){
File title = new File("E:\\JavaFiles\\BookDatabaseName.txt"); //database of book name
File author = new File("E:\\JavaFiles\\BookDatabaseAuthor.txt"); //database of the name of author
File genre = new File("E:\\JavaFiles\\BookDatabaseTheme.txt"); //database of genre of book
File rating = new File("E:\\JavaFiles\\Rating.txt"); //database of ratings of book
FileReader in;
BufferedReader readFile;
String lineOfText; //to store information that read from files
try {
in = new FileReader(title);
readFile = new BufferedReader(in);
for (int i = 0; i < 55; i++) {
lineOfText = readFile.readLine();
if (lineOfText != null) {
bookTitle[i] = lineOfText;
}//store titles of books in an array
}
readFile.close();
in.close();
in = new FileReader(author);
readFile = new BufferedReader(in);
for (int i = 0; i < 55; i++) {
lineOfText = readFile.readLine();
if (lineOfText != null) {
bookAuthor[i] = lineOfText;
}//store author names into array
}
readFile.close();
in.close();
in = new FileReader(genre);
readFile = new BufferedReader(in);
for (int i = 0; i < 55; i++) {
lineOfText = readFile.readLine();
if (lineOfText != null) {
bookGenre[i] = lineOfText;
}//store genres of book into array
}
readFile.close();
in.close();
in = new FileReader(rating);
readFile = new BufferedReader(in);
for (int j = 0; j < 55; j++){
ratingDataBase[1][j]=Integer.parseInt(readFile.readLine());
}//read and store reader numbers of books
for (int i = 0; i < 55; i++){
ratingDataBase[0][i] = Integer.parseInt(readFile.readLine());
}//read and store average ratings
} catch (FileNotFoundException e){
System.err.println("FileNotFoundExceotion:" + e.getMessage());
} catch (IOException e){
System.err.println("IOException: " + e.getMessage());
}
}
}