Skip to content

Commit

Permalink
Weekly updates for version loader and handler speed optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
layou233 committed Jan 8, 2021
1 parent fc24fab commit 50b392d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'lau'
version '1.0'
version '1.1'

repositories {
mavenCentral()
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/lau/NovelDL/UpdateCheck.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package lau.NovelDL;

import lau.NovelDL.utils.LoadFileResource;

import java.io.IOException;

/**
Expand All @@ -9,7 +11,7 @@
*/

public class UpdateCheck {
public static String version = "1.0";
public static String version = LoadFileResource.loadFile("version.txt");

public static void updateCheck() {
System.out.println("Version " + version);
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/lau/NovelDL/utils/LoadFileResource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package lau.NovelDL.utils;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

public class LoadFileResource {
public static String loadFile(String fileName) {
String log = null;
try {
InputStream is = LoadFileResource.class.getClassLoader().getResourceAsStream(fileName);
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
log = new String(buffer, StandardCharsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}
return log;
}
}
6 changes: 3 additions & 3 deletions src/main/kotlin/lau/NovelDL/NovelHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ fun readNovel(plain: String): String {
)

// Process " "s
novel = Regex(" ").replace(novel, " ")
novel = novel.replace(" "," ")

// Process """s
novel = Regex(""").replace(novel, "\"")
novel = novel.replace("&"","\"")

// Process "<br/?>"s
novel = Regex("<br/?>").replace(novel, "\n")
Expand All @@ -33,7 +33,7 @@ fun readNovel(plain: String): String {
novel = removePartsFromString(novel, "<p", ">", "\n")

// Process "</p>"s
novel = Regex("</p>").replace(novel, "\n")
novel = novel.replace("</p>","\n")

return "\n\n" + novel + "\n\n"
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0
1.1

0 comments on commit 50b392d

Please sign in to comment.