-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTry.java
52 lines (49 loc) · 1.79 KB
/
Try.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
import java.io.*; // Import the File class & FileNotFoundException
// import java.io.FileNotFoundException; // Import this class to handle errors
import java.util.Scanner; // Import the Scanner class to read text files
public class Try {
public static void main(String[] args) {
readFiles(args);
// String str = "abcdefgh";
// int temp_integer = 96; // for lower case
// for (char c : str.toCharArray()) {
// int temp = (int) c;
// if (temp <= 122 & temp >= 97)
// System.out.print(temp - temp_integer);
// }
}
public static void readFiles(String[] args) {
File layout = new File(args[0]);
File moves = new File(args[1]);
try {
// read layout
Scanner myReader = new Scanner(layout);
while (myReader.hasNextLine()) {
String line = myReader.nextLine();
if (line.startsWith("#")) {
// not read the layout input beginning with '#'
continue;
}
// do sth
String[] splitArray = line.split("=",2);
for(String a:splitArray)
System.out.println(a);
}
System.out.println("\n");
// read moves
myReader = new Scanner(moves);
while (myReader.hasNextLine()) {
String line = myReader.nextLine();
if (line.startsWith("#")) {
continue;
}
// do sth
System.out.println(line);
}
myReader.close();
} catch (FileNotFoundException e) {
System.out.println("An error occurred while reading the file.");
e.printStackTrace();
}
}
}