public final class TextAreaOutputStream extends OutputStream
Constructor and Description |
---|
TextAreaOutputStream(TextArea textArea) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
static PrintStream |
getTextPrintStream(TextArea textArea)
Factory method for creating a PrintStream to print to selected TextArea
|
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
write
public TextAreaOutputStream(TextArea textArea)
textArea
- area where to write#import java.io.*; #import javax.swing.*; JTextArea text = new JTextArea(); PrintStream tw = new PrintStream(new TextAreaOutputStream(text)); tw.print("Hello"); tw.print(" "); tw.print("world!"); tw.flush(); text.getText() === "Hello world!"; text.setText(""); tw.println("Hello"); tw.println("world!"); text.getText() =R= "Hello\\r?\\nworld!\\r?\\n";
public void flush()
flush
in interface Flushable
flush
in class OutputStream
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public static PrintStream getTextPrintStream(TextArea textArea)
textArea
- area where to print#import java.io.*; #import javax.swing.*; JTextArea text = new JTextArea(); PrintStream tw = TextAreaOutputStream.getTextPrintStream(text); tw.print("Hyvää"); // skandit toimi tw.print(" "); tw.print("päivää!"); text.getText() === "Hyvää päivää!"; text.setText(""); tw.print("ä"); text.getText() === "ä";