com.caucho.quercus.lib.file
Class BufferedBinaryInputOutput

java.lang.Object
  extended by com.caucho.quercus.lib.file.AbstractBinaryInputOutput
      extended by com.caucho.quercus.lib.file.BufferedBinaryInputOutput
All Implemented Interfaces:
BinaryInput, BinaryOutput, BinaryStream
Direct Known Subclasses:
TcpInputOutput

public abstract class BufferedBinaryInputOutput
extends AbstractBinaryInputOutput

Represents a Quercus file open for reading


Field Summary
 
Fields inherited from class com.caucho.quercus.lib.file.AbstractBinaryInputOutput
_env, _isEOF, _isTimeout, _lineReader
 
Fields inherited from interface com.caucho.quercus.lib.file.BinaryStream
SEEK_CUR, SEEK_END, SEEK_SET
 
Constructor Summary
protected BufferedBinaryInputOutput(Env env)
           
 
Method Summary
 long getPosition()
          Returns the current location in the file.
 void init(ReadStream is, WriteStream os)
           
 int read()
          Reads a character from a file, returning -1 on EOF.
 int read(char[] buffer, int offset, int length)
          Reads a buffer from a file, returning -1 on EOF.
 StringValue readLine(long length)
          Reads a line from a file, returning null on EOF.
 void setEncoding(java.lang.String encoding)
           
 boolean setPosition(long offset)
          Sets the current location in the file.
 Value stat()
          Returns an array filled with stat information.
 java.lang.String toString()
          Converts to a string.
 void unread()
          Unread the last byte.
 void writeToStream(java.io.OutputStream os, int length)
           
 
Methods inherited from class com.caucho.quercus.lib.file.AbstractBinaryInputOutput
appendTo, close, closeRead, closeWrite, flush, getEnv, getInputStream, getOutputStream, getResourceType, init, isEOF, isTimeout, openCopy, print, print, read, read, readOptionalLinefeed, seek, setTimeout, toJavaObject, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BufferedBinaryInputOutput

protected BufferedBinaryInputOutput(Env env)
Method Detail

init

public void init(ReadStream is,
                 WriteStream os)

setEncoding

public void setEncoding(java.lang.String encoding)
                 throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

unread

public void unread()
            throws java.io.IOException
Unread the last byte.

Specified by:
unread in interface BinaryInput
Specified by:
unread in class AbstractBinaryInputOutput
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Reads a character from a file, returning -1 on EOF.

Specified by:
read in interface BinaryInput
Overrides:
read in class AbstractBinaryInputOutput
Throws:
java.io.IOException

read

public int read(char[] buffer,
                int offset,
                int length)
         throws java.io.IOException
Reads a buffer from a file, returning -1 on EOF.

Throws:
java.io.IOException

writeToStream

public void writeToStream(java.io.OutputStream os,
                          int length)
                   throws java.io.IOException
Throws:
java.io.IOException

readLine

public StringValue readLine(long length)
                     throws java.io.IOException
Reads a line from a file, returning null on EOF.

Specified by:
readLine in interface BinaryInput
Overrides:
readLine in class AbstractBinaryInputOutput
Throws:
java.io.IOException

getPosition

public long getPosition()
Returns the current location in the file.

Specified by:
getPosition in interface BinaryInput
Specified by:
getPosition in interface BinaryStream
Specified by:
getPosition in class AbstractBinaryInputOutput

setPosition

public boolean setPosition(long offset)
Sets the current location in the file.

Specified by:
setPosition in interface BinaryInput
Specified by:
setPosition in interface BinaryStream
Specified by:
setPosition in class AbstractBinaryInputOutput

stat

public Value stat()
Description copied from interface: BinaryStream
Returns an array filled with stat information. Mainly for wrapped stream functionality.

Specified by:
stat in interface BinaryStream
Overrides:
stat in class AbstractBinaryInputOutput

toString

public java.lang.String toString()
Converts to a string.

Overrides:
toString in class AbstractBinaryInputOutput