* All files: Updated copyright to reflect Cygnus purchase.
[official-gcc.git] / libjava / java / io / PipedWriter.java
blob69a47ca80d4a9ab467b366abedbe4405ee6fcfb8
1 // PipedWriter.java - Piped character stream.
3 /* Copyright (C) 1998, 1999 Red Hat, Inc.
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 details. */
11 package java.io;
13 /**
14 * @author Tom Tromey <tromey@cygnus.com>
15 * @date September 25, 1998
18 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
19 * "The Java Language Specification", ISBN 0-201-63451-1
20 * Status: Complete to 1.1.
23 public class PipedWriter extends Writer
25 public void close () throws IOException
27 closed = true;
30 public void connect (PipedReader sink) throws IOException
32 if (closed)
33 throw new IOException ("already closed");
34 if (reader != null)
36 if (reader == sink)
37 return;
38 throw new IOException ("already connected");
40 try
42 reader = sink;
43 reader.connect(this);
45 catch (IOException e)
47 reader = null;
48 throw e;
52 public void flush () throws IOException
54 // We'll throw an exception if we're closed, but there's nothing
55 // else to do here.
56 if (closed)
57 throw new IOException ("closed");
60 public PipedWriter ()
62 super ();
63 closed = false;
66 public PipedWriter (PipedReader sink) throws IOException
68 super ();
69 closed = false;
70 connect (sink);
73 public void write (char buffer[], int offset, int count) throws IOException
75 if (closed)
76 throw new IOException ("closed");
77 reader.receive(buffer, offset, count);
80 boolean isClosed ()
82 return closed;
85 // The associated reader.
86 private PipedReader reader;
87 private boolean closed;