mirror of
https://github.com/quinton-ashley/java2js
synced 2024-12-29 10:11:54 +01:00
45 lines
774 B
JavaScript
Executable File
45 lines
774 B
JavaScript
Executable File
jre.imports['java.io.PrintStream'].load = () => {
|
|
class PrintStream {
|
|
constructor() {
|
|
this.log = '';
|
|
this.onPrint = () => {};
|
|
}
|
|
|
|
reset() {
|
|
this.log = '';
|
|
}
|
|
|
|
_onPrint(length) {
|
|
this.onPrint(length);
|
|
}
|
|
|
|
print(arg) {
|
|
let str = arg.toString();
|
|
this.log += str;
|
|
if (window?.ide) {
|
|
ide.log.value += str;
|
|
this._onPrint(str.length);
|
|
}
|
|
}
|
|
|
|
println(arg) {
|
|
let str = arg.toString() + '\n';
|
|
this.log += str;
|
|
if (window?.ide) {
|
|
ide.log.value += str;
|
|
this._onPrint(str.length);
|
|
}
|
|
}
|
|
|
|
printf(format, ...args) {
|
|
let str = new Formatter().format(format, args);
|
|
this.log += str;
|
|
if (window?.ide) {
|
|
ide.log.value += str;
|
|
this._onPrint(str.length);
|
|
}
|
|
}
|
|
}
|
|
jre.java.io.PrintStream = PrintStream;
|
|
};
|