Cross-Platform C++

ot::io
class FileInputStream

#include "ot/io/FileInputStream.h"

ot::io::InputStream ot::ManagedObject An InputStream that uses the contents of a file as its source. When a FileInputStream is created, a connection is established with an open file in the file system. The open file is represented by a FileDescriptor which ensures the file is closed when the FileInputStream is destroyed.




Constructor/Destructor Summary
FileInputStream(const File& file)
         Constructs a FileInputStream by opening a connection to the file with the abstract pathname denoted by file.
FileInputStream(const String& name)
         Constructs a FileInputStream by opening a connection to the named file name.
FileInputStream(FileDescriptor* pFD)
         Constructs a FileInputStream and connects it with an open file denoted by the FileDescriptor pFD.

Method Summary
 virtual void close()
         Closes the InputStream.
 RefPtr< FileDescriptor > getFD() const
         Returns a FileDescriptor for the open file connected to this FileInputStream.
 virtual long read(Byte* pBuffer, size_t bufLen)
         Reads up to bufLen bytes into the supplied buffer.

Methods inherited from class ot::io::InputStream
available, mark, markSupported, read, reset, skip

Methods inherited from class ot::ManagedObject
addRef, getRefCount, onFinalRelease, operator=, release

Constructor/Destructor Detail

FileInputStream

 FileInputStream(const File& file)
Constructs a FileInputStream by opening a connection to the file with the abstract pathname denoted by file.

Parameters:
file - the abstract pathname of the file to open
Exceptions:
FileNotFoundException - if a file with the specified name does not exist on the file system.
IOException - if the specified file could not be opened. This includes the case where file refers to a directory instead of a normal file.

FileInputStream

 FileInputStream(const String& name)
Constructs a FileInputStream by opening a connection to the named file name.

Parameters:
name - the name of the file to open
Exceptions:
FileNotFoundException - if a file with the specified name does not exist on the file system.
IOException - if the specified file name could not be opened. This includes the case where name refers to a directory instead of a normal file.

FileInputStream

 FileInputStream(FileDescriptor* pFD)
Constructs a FileInputStream and connects it with an open file denoted by the FileDescriptor pFD.

Parameters:
pFD - the FileDescriptor to connect to this FileInputStream
Exceptions:
NullPointerException - if pFD is null.

Method Detail

close

virtual void close()
Closes the InputStream. Once an InputStream is closed, all system resources associated with the stream are released, preventing any further read(), mark(), reset() or skip() operations. Further calls to close() have no effect.

Exceptions:
IOException - if an I/O error occurs.

getFD

RefPtr< FileDescriptorgetFD() const
Returns a FileDescriptor for the open file connected to this FileInputStream. A null RefPtr is returned if this FileInputStream has been closed.


read

virtual long read(Byte* pBuffer,
                  size_t bufLen)
Reads up to bufLen bytes into the supplied buffer.

Parameters:
pBuffer - A pointer to the buffer into which the bytes will be copied. This must be capable of holding at least bufLen bytes.
bufLen - The maximum number of bytes to read into the passed buffer. If this exceeds the maximum value that can be represented by a long integer, it is reduced to a value that can be so represented.
Returns:
The number of bytes read or InputStream::EndOfFile if the end of the stream has been reached.
Exceptions:
IllegalArgumentException - if bufLen is zero
NullPointerException - if pBuffer is null
IOException - if an error occurs while reading from the byte stream


Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2003 ElCel Technology   Trademark Acknowledgements