 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.utils;
22 import java.io.CharArrayWriter;
23 import java.io.IOException;
24 import java.io.Reader;
25 import org.jetbrains.annotations.NotNull;
26 import org.jetbrains.annotations.Nullable;
45 private final Object
sync =
new Object();
68 private final Runnable
runnable =
new Runnable() {
72 final char[] buf =
new char[1024];
73 while (!Thread.currentThread().isInterrupted()) {
75 final int len =
reader.read(buf);
85 }
catch (
final IOException ex) {
127 synchronized (
sync) {
129 if (this.failure ==
null) {
141 synchronized (
sync) {
154 synchronized (
sync) {
166 public void join() throws InterruptedException {
boolean stopped
Whether the worker thread was stopped.
final Reader reader
The Reader to read from.
final Object sync
The synchronization object for accessing stopped, {}, and #charArrayWriter}.
void start()
Starts reading.
String getOutput()
Returns the reader's output.
CopyReader(@NotNull final Reader reader)
Creates a new instance.
void join()
Waits for the worker thread to terminate.
final Runnable runnable
The Runnable implementing the worker thread.
final CharArrayWriter charArrayWriter
The CharArrayWriter collecting data read from reader.
void stop()
Stops reading.
void setFailure(@NotNull final String failure)
Sets the failure reason.
Copies a Reader into a String.
String getFailure()
Returns the failure reason.
String failure
The failure reason.
final Thread thread
The worker Thread executing runnable.