1
0
mirror of https://github.com/quinton-ashley/java2js synced 2024-12-29 10:11:54 +01:00
This commit is contained in:
Quinton Ashley 2022-04-22 14:00:18 -05:00
parent ab8675e241
commit f122d89264
3 changed files with 13 additions and 3 deletions

View File

@ -1,4 +1,9 @@
jdk.imports['java.io.FileNotFoundException'].load = async () => {
class FileNotFoundException {}
class FileNotFoundException extends Exception {
constructor(msg) {
super(msg);
this.name = 'FileNotFoundException';
}
}
jdk.java.io.FileNotFoundException = FileNotFoundException;
};

View File

@ -1,5 +1,6 @@
jdk.imports['java.util.Scanner'].load = async () => {
const InputStream = await jdk.import('java.io.InputStream');
const FileNotFoundException = await jdk.import('java.io.FileNotFoundException');
class Scanner {
constructor(input) {
@ -12,7 +13,11 @@ jdk.imports['java.util.Scanner'].load = async () => {
}
async _loadFile(filePath) {
this.in = new InputStream();
this.in.stream = await (await fetch(filePath)).text();
let data = await fetch(filePath);
if (data.status == 404 || data.status == 403) {
throw new FileNotFoundException(filePath);
}
this.in.stream = await data.text();
this._loading = false;
}
async hasNext(pattern) {

View File

@ -1,6 +1,6 @@
{
"name": "java2js",
"version": "1.2.6",
"version": "1.2.7",
"description": "Converts Java to JavaScript and runs it with a JS JDK",
"main": "jdk.js",
"scripts": {