Skip to content

Commit

Permalink
Can't have shit working with Java
Browse files Browse the repository at this point in the history
  • Loading branch information
XorTroll committed Aug 20, 2023
1 parent 7a29e66 commit b921e75
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion emuiigen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.12.0</version>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
Expand Down
6 changes: 3 additions & 3 deletions emuiigen/src/AmiiboAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package com.xortroll.emuiibo.emuiigen

import org.json.JSONObject
import org.json.JSONArray
import java.io.File
import java.io.FileWriter
import java.io.FileInputStream
import java.net.URLDecoder
import java.nio.file.Path
import java.nio.file.Paths
import org.apache.commons.io.IOUtils
Expand Down Expand Up @@ -35,8 +35,8 @@ class AmiiboAPI {
}

fun readApi() : Map<String, List<AmiiboAPIEntry>>? {
val cur_path = Path.of(URLDecoder.decode(this::class.java.getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8")).parent;
val local_api_json_path = Paths.get(cur_path.toAbsolutePath().toString(), "api.json").toString();
val cur_path = File(this::class.java.getProtectionDomain().getCodeSource().getLocation().toURI()).parentFile.absolutePath;
val local_api_json_path = Paths.get(cur_path, "api.json").toString();

try {
val raw_json = Utils.netDownloadString(Url);
Expand Down
8 changes: 1 addition & 7 deletions emuiigen/src/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@ class Utils {
).toUShort()
}

fun netDownloadBytes(url: String) : ByteArray {
val strm = URL(url).openStream();
return IOUtils.toByteArray(strm);
}

fun netDownloadString(url: String) : String {
val strm = URL(url).openStream();
return IOUtils.toString(strm, StandardCharsets.UTF_8);
return IOUtils.toString(URL(url));
}

fun netDownloadFile(url: String, path: String) {
Expand Down

0 comments on commit b921e75

Please sign in to comment.