org.openide.util.io
Class ReaderInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--org.openide.util.io.ReaderInputStream

public class ReaderInputStream
extends InputStream

This class convert Reader to InputStream. It works by converting the characters to the encoding specified in constructor parameter. Default enconding is ISO-8859-1.


Constructor Summary
ReaderInputStream(Reader reader)
          Creates new input stream from the given reader.
ReaderInputStream(Reader reader, String encoding)
          Creates new input stream from the given reader and encoding.
 
Method Summary
 int available()
          Returns the number of bytes that can be read from this input stream without blocking.
 void close()
          Closes this input stream and releases any system resources associated with the stream.
 int read()
          Reads the next byte of data from this input stream.
 long skip(long n)
          Skips over and discards n bytes of data from this input stream.
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReaderInputStream

public ReaderInputStream(Reader reader)
                  throws IOException
Creates new input stream from the given reader.
Parameters:
reader - Input reader

ReaderInputStream

public ReaderInputStream(Reader reader,
                         String encoding)
                  throws IOException
Creates new input stream from the given reader and encoding.
Parameters:
reader - Input reader
encoding -  
Method Detail

read

public int read()
         throws IOException
Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Overrides:
read in class InputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
IOException - if an I/O error occurs.

skip

public long skip(long n)
          throws IOException
Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.
Overrides:
skip in class InputStream
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
IOException - if an I/O error occurs.

available

public int available()
              throws IOException
Returns the number of bytes that can be read from this input stream without blocking.
Overrides:
available in class InputStream
Returns:
the number of bytes that can be read from this input stream without blocking.
Throws:
IOException - if an I/O error occurs.

close

public void close()
           throws IOException
Closes this input stream and releases any system resources associated with the stream.
Overrides:
close in class InputStream
Throws:
IOException - if an I/O error occurs.


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.