1
0
mirror of https://github.com/quinton-ashley/java2js synced 2024-12-29 10:11:54 +01:00
java2js/jdk/java/io/PrintStream.js
Quinton Ashley c66d7d7162 1.0.8
2021-11-15 20:02:30 -05:00

45 lines
771 B
JavaScript
Executable File

jdk.imports['java.io.PrintStream'].load = async () => {
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 = String.format(format, args);
this.log += str;
if (window?.ide) {
ide.log.value += str;
this._onPrint(str.length);
}
}
}
jdk.java.io.PrintStream = PrintStream;
};