Inheritance: java.io.Reader
示例#1
0
        /// <summary>
        /// Connects this piped writer to a receiver. If this object
        /// is already connected to some other piped reader, an
        /// <code>IOException</code> is thrown.
        /// <para>
        /// If <code>snk</code> is an unconnected piped reader and
        /// <code>src</code> is an unconnected piped writer, they may
        /// be connected by either the call:
        /// <blockquote><pre>
        /// src.connect(snk)</pre></blockquote>
        /// or the call:
        /// <blockquote><pre>
        /// snk.connect(src)</pre></blockquote>
        /// The two calls have the same effect.
        ///
        /// </para>
        /// </summary>
        /// <param name="snk">   the piped reader to connect to. </param>
        /// <exception cref="IOException">  if an I/O error occurs. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public synchronized void connect(PipedReader snk) throws IOException
        public virtual void Connect(PipedReader snk)
        {
            lock (this)
            {
                if (snk == null)
                {
                    throw new NullPointerException();
                }
                else if (Sink != null || snk.Connected)
                {
                    throw new IOException("Already connected");
                }
                else if (snk.ClosedByReader || Closed)
                {
                    throw new IOException("Pipe closed");
                }

                Sink          = snk;
                snk.@in       = -1;
                snk.@out      = 0;
                snk.Connected = true;
            }
        }
示例#2
0
        /// <summary>
        /// Creates a piped writer connected to the specified piped
        /// reader. Data characters written to this stream will then be
        /// available as input from <code>snk</code>.
        /// </summary>
        /// <param name="snk">   The piped reader to connect to. </param>
        /// <exception cref="IOException">  if an I/O error occurs. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public PipedWriter(PipedReader snk) throws IOException
        public PipedWriter(PipedReader snk)
        {
            Connect(snk);
        }