Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.caucho.vfs
Class VfsStream

    java.lang.Object
      |
      +--com.caucho.vfs.StreamImpl
            |
            +--com.caucho.vfs.VfsStream

public class VfsStream
extends StreamImpl

Stream encapsulating InputStream/OutputStream.

Fields inherited from class com.caucho.vfs.StreamImpl
`nullPath, path`

Constructor Summary
`VfsStream()` Create an empty VfsStream.
`VfsStream(java.io.InputStream is, java.io.OutputStream os)` Create a new VfsStream based on the java.io.* stream.
`VfsStream(java.io.InputStream is, java.io.OutputStream os, Path path)`

Method Summary
`boolean` | `canRead()` Returns true if this is a read stream.
`boolean` | `canWrite()` Returns true if this is a writable stream.
`void` | `close()` Closes the stream.
`void` | `flush()` Flushes the write output.
`int` | `getAvailable()` Returns the number of bytes available without blocking.
`boolean` | `getFlushOnNewline()` Returns true if the buffer should be flushed on every newline.
`byte[]` | `getNewline()` Returns the stream's natural newline character.
`long` | `getReadPosition()` Returns the current read position of the underlying file.
`boolean` | `hasSkip()` Returns true if the stream implements skip.
`void` | `init(java.io.InputStream is, java.io.OutputStream os)` Initializes a VfsStream with an input/output stream pair.
`static ReadStream` | `openRead(java.io.InputStream is)` Opens a read stream based on a java.io.InputStream.
`static ReadStream` | `openRead(java.io.InputStream is, WriteStream ws)`
`static ReadWritePair` | `openReadWrite(java.io.InputStream is, java.io.OutputStream os)`
`static WriteStream` | `openWrite(java.io.OutputStream os)`
`int` | `read(byte[] buf, int offset, int length)` Reads the next chunk from the stream.
`void` | `setCloseChildOnClose(boolean close)`
`void` | `setFlushOnNewline(boolean value)`
`void` | `setNewline(byte[] newline)`
`long` | `skip(long n)` Skips a number of bytes, returning the bytes skipped.
`void` | `write(byte[] buf, int offset, int length, boolean isEnd)` Writes a buffer to the underlying stream.

Methods inherited from class com.caucho.vfs.StreamImpl
`clearWrite, getAttribute, getAttributeNames, getPath, removeAttribute, setAttribute, setPath`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### VfsStream

    public VfsStream()

  Create an empty VfsStream.

### VfsStream

    public VfsStream(java.io.InputStream is,
                     java.io.OutputStream os)

  Create a new VfsStream based on the java.io.* stream.

### VfsStream

    public VfsStream(java.io.InputStream is,
                     java.io.OutputStream os,
                     Path path)

Method Detail

### init

    public void init(java.io.InputStream is,
                     java.io.OutputStream os)

  Initializes a VfsStream with an input/output stream pair. Before a read, the output will be flushed to avoid deadlocks.
  Parameters:
    `is` - the underlying InputStream.
    `os` - the underlying OutputStream.

### setNewline

    public void setNewline(byte[] newline)

### getNewline

    public byte[] getNewline()

  Description copied from class: `StreamImpl`
  Returns the stream's natural newline character.
  Overrides:
    `getNewline` in class `StreamImpl`

### openReadWrite

    public static ReadWritePair openReadWrite(java.io.InputStream is,
                                              java.io.OutputStream os)

### openRead

    public static ReadStream openRead(java.io.InputStream is)

  Opens a read stream based on a java.io.InputStream.
  Parameters:
    `is` - the underlying InputStream.
  Returns:
    the new ReadStream

### openRead

    public static ReadStream openRead(java.io.InputStream is,
                                      WriteStream ws)

### openWrite

    public static WriteStream openWrite(java.io.OutputStream os)

### canRead

    public boolean canRead()

  Description copied from class: `StreamImpl`
  Returns true if this is a read stream.
  Overrides:
    `canRead` in class `StreamImpl`

### read

    public int read(byte[] buf,
                    int offset,
                    int length)
             throws java.io.IOException

  Description copied from class: `StreamImpl`
  Reads the next chunk from the stream.
  Overrides:
    `read` in class `StreamImpl`
  Following copied from class: `com.caucho.vfs.StreamImpl`
  Parameters:
    `buffer` - byte array receiving the data.
    `offset` - starting offset into the array.
    `length` - number of bytes to read.
  Returns:
    the number of bytes read or -1 on end of file.

### hasSkip

    public boolean hasSkip()

  Description copied from class: `StreamImpl`
  Returns true if the stream implements skip.
  Overrides:
    `hasSkip` in class `StreamImpl`

### skip

    public long skip(long n)
              throws java.io.IOException

  Description copied from class: `StreamImpl`
  Skips a number of bytes, returning the bytes skipped.
  Overrides:
    `skip` in class `StreamImpl`
  Following copied from class: `com.caucho.vfs.StreamImpl`
  Parameters:
    `n` - the number of types to skip.
  Returns:
    the actual bytes skipped.

### getAvailable

    public int getAvailable()
                     throws java.io.IOException

  Description copied from class: `StreamImpl`
  Returns the number of bytes available without blocking. Depending on the stream, this may return less than the actual bytes, but will always return a number > 0 if there is any data available.
  Overrides:
    `getAvailable` in class `StreamImpl`

### getReadPosition

    public long getReadPosition()

  Description copied from class: `StreamImpl`
  Returns the current read position of the underlying file.
  Overrides:
    `getReadPosition` in class `StreamImpl`

### canWrite

    public boolean canWrite()

  Description copied from class: `StreamImpl`
  Returns true if this is a writable stream.
  Overrides:
    `canWrite` in class `StreamImpl`

### getFlushOnNewline

    public boolean getFlushOnNewline()

  Description copied from class: `StreamImpl`
  Returns true if the buffer should be flushed on every newline. This is typically only true for error streams like stderr:.
  Overrides:
    `getFlushOnNewline` in class `StreamImpl`

### setFlushOnNewline

    public void setFlushOnNewline(boolean value)

### write

    public void write(byte[] buf,
                      int offset,
                      int length,
                      boolean isEnd)
               throws java.io.IOException

  Writes a buffer to the underlying stream.
  Overrides:
    `write` in class `StreamImpl`
  Parameters:
    `buffer` - the byte array to write.
    `offset` - the offset into the byte array.
    `length` - the number of bytes to write.
    `isEnd` - true when the write is flushing a close.

### flush

    public void flush()
               throws java.io.IOException

  Description copied from class: `StreamImpl`
  Flushes the write output.
  Overrides:
    `flush` in class `StreamImpl`

### setCloseChildOnClose

    public void setCloseChildOnClose(boolean close)

### close

    public void close()
               throws java.io.IOException

  Description copied from class: `StreamImpl`
  Closes the stream.
  Overrides:
    `close` in class `StreamImpl`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD