bcv-vf/src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/JTextAreaOutputStream.java

32 lines
568 B
Java
Raw Normal View History

2021-06-22 00:46:57 +00:00
package the.bytecode.club.bytecodeviewer.gui.extras;
import javax.swing.*;
import java.io.IOException;
import java.io.OutputStream;
/**
* @author Konloch
* @since 6/21/2021
*/
public class JTextAreaOutputStream extends OutputStream
{
private final StringBuilder sb = new StringBuilder();
private final JTextArea textArea;
public JTextAreaOutputStream(JTextArea textArea)
{
this.textArea = textArea;
}
public void update()
{
textArea.append(sb.toString());
}
@Override
public void write(int b) throws IOException
{
sb.append((char) b);
}
}