Skip to content

Commit 1b8458d

Browse files
committed
fixed js files not in build package
1 parent d394c9d commit 1b8458d

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/main/java/iotaFlashWrapper/IotaFlashBridge.java

+15-10
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@
44
import iotaFlashWrapper.Model.*;
55

66

7+
import java.io.File;
8+
import java.io.FileInputStream;
79
import java.io.IOException;
10+
import java.net.URL;
811
import java.nio.charset.Charset;
912
import java.nio.file.Files;
1013
import java.nio.file.Paths;
1114
import java.util.ArrayList;
1215
import java.util.List;
1316
import java.util.Map;
1417

18+
import static java.nio.file.Files.readAllBytes;
19+
1520
public class IotaFlashBridge {
16-
private static String iotaLibPath = "res/iota.flash.js";
17-
private static String iotaHelperLibPath = "res/iota.flash.helper.js";
21+
private static String iotaLibPath = "iota.flash.js";
22+
private static String iotaHelperLibPath = "iota.flash.helper.js";
1823
private static V8 engine;
1924
private static V8Object transfer;
2025
private static V8Object multisig;
@@ -301,13 +306,13 @@ public static FlashObject applyTransfersToUser(UserObject user, ArrayList<Bundle
301306
static String readFile(String path, Charset encoding)
302307
throws IOException
303308
{
304-
byte[] encoded;
305-
try {
306-
encoded = Files.readAllBytes(Paths.get(path));
307-
} catch (IOException error) {
308-
System.out.println("Failed to load file: " + error.getLocalizedMessage());
309-
return "";
310-
}
311-
return new String(encoded, encoding);
309+
URL url = IotaFlashBridge.class.getClassLoader().getResource(path);
310+
File file = new File(url.getPath());
311+
FileInputStream fis = new FileInputStream(file);
312+
byte[] data = new byte[(int) file.length()];
313+
fis.read(data);
314+
fis.close();
315+
316+
return new String(data, "UTF-8");
312317
}
313318
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)