2021-06-26 01:13:46 +00:00
|
|
|
package the.bytecode.club.bytecodeviewer.gui.components;
|
2021-06-22 00:46:57 +00:00
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
import java.io.OutputStream;
|
2021-07-07 04:21:06 +00:00
|
|
|
import java.io.PrintStream;
|
2021-06-22 00:46:57 +00:00
|
|
|
|
2021-06-26 03:33:06 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
|
|
|
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2021-06-22 00:46:57 +00:00
|
|
|
/**
|
|
|
|
* @author Konloch
|
|
|
|
* @since 6/21/2021
|
|
|
|
*/
|
|
|
|
public class JTextAreaOutputStream extends OutputStream
|
|
|
|
{
|
2021-07-07 23:49:06 +00:00
|
|
|
private StringBuilder sb = new StringBuilder();
|
2021-06-22 00:46:57 +00:00
|
|
|
private final JTextArea textArea;
|
2021-07-07 04:21:06 +00:00
|
|
|
private final PrintStream og;
|
2021-06-22 00:46:57 +00:00
|
|
|
|
2021-07-07 04:21:06 +00:00
|
|
|
public JTextAreaOutputStream(JTextArea textArea, PrintStream og)
|
2021-06-22 00:46:57 +00:00
|
|
|
{
|
|
|
|
this.textArea = textArea;
|
2021-07-07 04:21:06 +00:00
|
|
|
this.og = og;
|
2021-06-22 00:46:57 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 23:49:06 +00:00
|
|
|
public boolean noUpdateRequired()
|
|
|
|
{
|
|
|
|
return sb.length() <= 0;
|
|
|
|
}
|
|
|
|
|
2021-06-22 00:46:57 +00:00
|
|
|
public void update()
|
|
|
|
{
|
|
|
|
textArea.append(sb.toString());
|
2021-07-07 23:49:06 +00:00
|
|
|
sb = new StringBuilder();
|
2021-06-22 00:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-07-07 23:49:06 +00:00
|
|
|
public void write(int b)
|
2021-06-22 00:46:57 +00:00
|
|
|
{
|
|
|
|
sb.append((char) b);
|
2021-07-07 04:21:06 +00:00
|
|
|
og.write(b);
|
2021-06-22 00:46:57 +00:00
|
|
|
}
|
|
|
|
}
|