mirror of https://github.com/apache/lucene.git
removed System.out
This commit is contained in:
parent
76e976167d
commit
cefe159ce0
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package org.apache.lucene.luke.app.desktop.util;
|
package org.apache.lucene.luke.app.desktop.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
|
@ -24,20 +26,32 @@ import javax.swing.JTextArea;
|
||||||
/** PrintStream for text areas */
|
/** PrintStream for text areas */
|
||||||
public final class TextAreaPrintStream extends PrintStream {
|
public final class TextAreaPrintStream extends PrintStream {
|
||||||
|
|
||||||
private final JTextArea textArea;
|
private final JTextArea textArea;
|
||||||
|
|
||||||
public TextAreaPrintStream(JTextArea textArea) {
|
public TextAreaPrintStream(JTextArea textArea) {
|
||||||
super(System.out, false, StandardCharsets.UTF_8);
|
super(new OutputStream() {
|
||||||
this.textArea = textArea;
|
@Override
|
||||||
}
|
public void write(int b) throws IOException {
|
||||||
|
textArea.append(String.valueOf((char) b));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flush() {
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
textArea.append(toString());
|
String s = new String(b, off, len, StandardCharsets.UTF_8);
|
||||||
clear();
|
textArea.append(s);
|
||||||
}
|
}
|
||||||
|
}, false, StandardCharsets.UTF_8);
|
||||||
public void clear() {
|
|
||||||
textArea.setText("");
|
this.textArea = textArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flush() {
|
||||||
|
textArea.repaint(); // Optional: Repaint the text area after appending text
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
textArea.setText("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue