-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadPDF.java
More file actions
84 lines (64 loc) · 2.55 KB
/
Copy pathreadPDF.java
File metadata and controls
84 lines (64 loc) · 2.55 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
class readPDF {
public static String numConverter(int i) {
String num = "";
// Store the number as a string based on its digits
if (i < 10) {
num = "00" + Integer.toString(i);
} else if (i < 100) {
num = "0" + Integer.toString(i);
} else if (i < 1000) {
num = Integer.toString(i);
}
return num;
}
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
// Prompt the user to determind the scale of the files to parse
System.out.println();
System.out.println("Enter your CSE course number(2221 or 2231)");
System.out.print("Or type nothing to exit: ");
int cseNum = scnr.nextInt();
ArrayList<Integer> cA = new ArrayList<>();
cA.add(2221);
cA.add(2231);
// Prompt again until the user type nothing or an appropriate course number
while (!cA.contains(cseNum)) {
if (Integer.toString(cseNum).isEmpty()) {
System.out.println("Goodbye!");
System.exit(0);
}
System.out.println();
System.out.println("Wrong CSE number, type again");
System.out.println("Enter your CSE course number(2221 or 2231)");
System.out.print("Or type nothing to exit: ");
cseNum = scnr.nextInt();
}
System.out.println();
System.out.print("Enter the starting course meeting number: ");
int startNum = scnr.nextInt();
System.out.print("Enter the ending course meething number: ");
int endNum = scnr.nextInt();
// Create a directory to store a pdf
fileGenerator.generateDirectory();
// Set a linked map to store the pdf links
Map<String, String> links = new LinkedHashMap<>();
// Loop to get pdf links from each html and store them in the map
for (int i = startNum; i <= endNum; i++) {
String meetingNum = numConverter(i);
if (cseNum == 2231) {
links.putAll(getURL.pdfLinkGenerator2231(meetingNum));
} else if (cseNum == 2221) {
links.putAll(getURL.pdfLinkGenerator2221(meetingNum));
}
}
// Download the pdf files and merge them in a one pdf
downLoadPDF.mergePDF(links);
// Print out the success message
System.out.println("Download success");
scnr.close();
}
}