fixed js files not in build package

This commit is contained in:
gosticks
2018-01-15 19:29:01 +01:00
parent d394c9d227
commit 1b8458d824
3 changed files with 15 additions and 10 deletions

View File

@@ -4,7 +4,10 @@ import com.eclipsesource.v8.utils.V8ObjectUtils;
import iotaFlashWrapper.Model.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -12,9 +15,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static java.nio.file.Files.readAllBytes;
public class IotaFlashBridge {
private static String iotaLibPath = "res/iota.flash.js";
private static String iotaHelperLibPath = "res/iota.flash.helper.js";
private static String iotaLibPath = "iota.flash.js";
private static String iotaHelperLibPath = "iota.flash.helper.js";
private static V8 engine;
private static V8Object transfer;
private static V8Object multisig;
@@ -301,13 +306,13 @@ public class IotaFlashBridge {
static String readFile(String path, Charset encoding)
throws IOException
{
byte[] encoded;
try {
encoded = Files.readAllBytes(Paths.get(path));
} catch (IOException error) {
System.out.println("Failed to load file: " + error.getLocalizedMessage());
return "";
}
return new String(encoded, encoding);
URL url = IotaFlashBridge.class.getClassLoader().getResource(path);
File file = new File(url.getPath());
FileInputStream fis = new FileInputStream(file);
byte[] data = new byte[(int) file.length()];
fis.read(data);
fis.close();
return new String(data, "UTF-8");
}
}