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) |
writepublic 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 Flushableflush in class OutputStreampublic void close()
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreampublic void write(int b) throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b, int off, int len) throws IOException
write in class OutputStreamIOExceptionpublic 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() === "ä";