IT. Expert System.

Android Reference

PipedReader


java.io

Class PipedReader

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Readable


    public class PipedReader
    extends Reader
    Receives information on a communications pipe. When two threads want to pass data back and forth, one creates a piped writer and the other creates a piped reader.
    See Also:
    PipedWriter
    • Constructor Detail

      • PipedReader

        public PipedReader()
        Constructs a new unconnected PipedReader. The resulting reader must be connected to a PipedWriter before data may be read from it.
      • PipedReader

        public PipedReader(PipedWriter out)
                    throws IOException
        Constructs a new PipedReader connected to the PipedWriter out. Any data written to the writer can be read from the this reader.
        Parameters:
        out - the PipedWriter to connect to.
        Throws:
        IOException - if out is already connected.
      • PipedReader

        public PipedReader(int pipeSize)
        Constructs a new unconnected PipedReader with the given buffer size. The resulting reader must be connected to a PipedWriter before data may be read from it.
        Parameters:
        pipeSize - the size of the buffer in chars.
        Throws:
        IllegalArgumentException - if pipeSize is less than or equal to zero.
        Since:
        1.6
      • PipedReader

        public PipedReader(PipedWriter out,
                   int pipeSize)
                    throws IOException
        Constructs a new PipedReader connected to the given PipedWriter, with the given buffer size. Any data written to the writer can be read from this reader.
        Parameters:
        out - the PipedWriter to connect to.
        pipeSize - the size of the buffer in chars.
        Throws:
        IOException - if an I/O error occurs
        IllegalArgumentException - if pipeSize is less than or equal to zero.
        Since:
        1.6
    • Method Detail

      • close

        public void close()
                   throws IOException
        Closes this reader. This implementation releases the buffer used for the pipe and notifies all threads waiting to read or write.
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in class Reader
        Throws:
        IOException - if an error occurs while closing this reader.
      • connect

        public void connect(PipedWriter src)
                     throws IOException
        Connects this PipedReader to a PipedWriter. Any data written to the writer becomes readable in this reader.
        Parameters:
        src - the writer to connect to.
        Throws:
        IOException - if this reader is closed or already connected, or if src is already connected.
      • read

        public int read()
                 throws IOException
        Reads a single character from this reader and returns it as an integer with the two higher-order bytes set to 0. Returns -1 if the end of the reader has been reached. If there is no data in the pipe, this method blocks until data is available, the end of the reader is detected or an exception is thrown.

        Separate threads should be used to read from a PipedReader and to write to the connected PipedWriter. If the same thread is used, a deadlock may occur.

        Overrides:
        read in class Reader
        Returns:
        the character read or -1 if the end of the reader has been reached.
        Throws:
        IOException - if this reader is closed or some other I/O error occurs.
      • read

        public int read(char[] buffer,
               int offset,
               int count)
                 throws IOException
        Reads at most count characters from this reader and stores them in the character array buffer starting at offset. If there is no data in the pipe, this method blocks until at least one byte has been read, the end of the reader is detected or an exception is thrown.

        Separate threads should be used to read from a PipedReader and to write to the connected PipedWriter. If the same thread is used, a deadlock may occur.

        Specified by:
        read in class Reader
        Parameters:
        buffer - the character array in which to store the characters read.
        offset - the initial position in bytes to store the characters read from this reader.
        count - the maximum number of characters to store in buffer.
        Returns:
        the number of characters read or -1 if the end of the reader has been reached.
        Throws:
        IndexOutOfBoundsException - if offset < 0 or count < 0, or if offset + count is greater than the size of buffer.
        InterruptedIOException - if the thread reading from this reader is interrupted.
        IOException - if this reader is closed or not connected to a writer, or if the thread writing to the connected writer is no longer alive.
      • ready

        public boolean ready()
                      throws IOException
        Indicates whether this reader is ready to be read without blocking. Returns true if this reader will not block when read is called, false if unknown or blocking will occur. This implementation returns true if the internal buffer contains characters that can be read.
        Overrides:
        ready in class Reader
        Returns:
        always false.
        Throws:
        IOException - if this reader is closed or not connected, or if some other I/O error occurs.
        See Also:
        read(), read(char[], int, int)


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 154 / 158680613. Delta: 0.04123 с