public class

DataTransferer.ReencodingInputStream

extends InputStream
java.lang.Object
   ↳ java.io.InputStream
     ↳ sun.awt.datatransfer.DataTransferer.ReencodingInputStream

Class Overview

Used for decoding and reencoding an InputStream on demand so that we can strip NUL terminators and perform EOLN search-and-replace.

Summary

Fields
protected CharsetEncoder encoder
protected char[] eoln
protected boolean eos
protected final char[] in
protected CharBuffer inBuf
protected int index
protected int limit
protected int numTerminators
protected byte[] out
protected ByteBuffer outBuf
protected BufferedReader wrapped
Public Constructors
DataTransferer.ReencodingInputStream(InputStream bytestream, long format, String targetEncoding, Transferable localeTransferable)
Public Methods
int available()
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.
void close()
Closes this input stream and releases any system resources associated with the stream.
int read()
Reads the next byte of data from the input stream.
[Expand]
Inherited Methods
From class java.io.InputStream
From class java.lang.Object
From interface java.io.Closeable

Fields

protected CharsetEncoder encoder

protected char[] eoln

protected boolean eos

protected final char[] in

protected CharBuffer inBuf

protected int index

protected int limit

protected int numTerminators

protected byte[] out

protected ByteBuffer outBuf

protected BufferedReader wrapped

Public Constructors

public DataTransferer.ReencodingInputStream (InputStream bytestream, long format, String targetEncoding, Transferable localeTransferable)

Throws
IOException

Public Methods

public int available ()

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. The next invocation might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

A subclass' implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the close() method.

The available method for class InputStream always returns 0.

This method should be overridden by subclasses.

Returns
  • an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking or 0 when it reaches the end of the input stream.
Throws
IOException

public void close ()

Closes this input stream and releases any system resources associated with the stream.

The close method of InputStream does nothing.

Throws
IOException

public int read ()

Reads the next byte of data from the 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.

A subclass must provide an implementation of this method.

Returns
  • the next byte of data, or -1 if the end of the stream is reached.
Throws
IOException