Clean up formatting & Update NIO in some remaining files

This commit is contained in:
Đạt Nhân Trương
2022-08-01 14:25:32 +07:00
parent a44744c05b
commit 4496e0854f
29 changed files with 603 additions and 613 deletions

View File

@@ -248,61 +248,58 @@ public class GachaponItemIdRetriever {
}
private static void fetchDataOnMapleHandbook() throws SQLException {
String line;
try(BufferedReader bufferedReader = Files.newBufferedReader(INPUT_FILE)) {
int skip = 0;
boolean lineHeader = false;
while ((line = bufferedReader.readLine()) != null) {
if (skip > 0) {
skip--;
String line;
try (BufferedReader bufferedReader = Files.newBufferedReader(INPUT_FILE)) {
int skip = 0;
boolean lineHeader = false;
while ((line = bufferedReader.readLine()) != null) {
if (skip > 0) {
skip--;
if (lineHeader) {
if (!line.isEmpty()) {
lineHeader = false;
printWriter.println();
printWriter.println(line + ":");
}
}
} else if (line.isEmpty()) {
printWriter.println("");
if (lineHeader) {
if (!line.isEmpty()) {
lineHeader = false;
printWriter.println();
printWriter.println(line + ":");
}
}
} else if (line.isEmpty()) {
printWriter.println("");
} else if (line.startsWith("Gachapon ")) {
String[] s = line.split("<EFBFBD> ");
String gachaponName = s[s.length - 1];
gachaponName = gachaponName.replace(" ", "_");
gachaponName = gachaponName.toLowerCase();
String[] s = line.split("<EFBFBD> ");
String gachaponName = s[s.length - 1];
gachaponName = gachaponName.replace(" ", "_");
gachaponName = gachaponName.toLowerCase();
if (printWriter != null) {
printWriter.close();
}
Path outputFile = OUTPUT_DIRECTORY.resolve(gachaponName + ".txt");
setupDirectories(outputFile);
if (printWriter != null) {
printWriter.close();
}
Path outputFile = OUTPUT_DIRECTORY.resolve(gachaponName + ".txt");
setupDirectories(outputFile);
printWriter = new PrintWriter(Files.newOutputStream(outputFile));
printWriter = new PrintWriter(Files.newOutputStream(outputFile));
skip = 2;
lineHeader = true;
} else if (line.startsWith(".")) {
skip = 1;
lineHeader = true;
} else {
line = line.replace("<EFBFBD>", "'");
skip = 2;
lineHeader = true;
} else if (line.startsWith(".")) {
skip = 1;
lineHeader = true;
} else {
line = line.replace("<EFBFBD>", "'");
for (String item : line.split("\\s\\|\\s")) {
item = item.trim();
if (!item.contentEquals("n/a")) {
String[] itemInfo = item.split(" - ");
fetchLineOnMapleHandbook(itemInfo[0], itemInfo.length > 1 ? itemInfo[1] : null);
}
}
}
}
} catch (IOException ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
}
}
item = item.trim();
if (!item.contentEquals("n/a")) {
String[] itemInfo = item.split(" - ");
fetchLineOnMapleHandbook(itemInfo[0], itemInfo.length > 1 ? itemInfo[1] : null);
}
}
}
}
} catch (IOException ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
}
}
private static void setupDirectories(Path file) {
if(!Files.exists(file.getParent())) {