public class FileStream extends Stream
Modifier | Constructor and Description |
---|---|
protected |
FileStream() |
|
FileStream(java.lang.String path,
FileMode mode)
When it is called by trusted applications, initializes a new instance of the System.IO.FileStream class with the specified path and creation mode.
|
|
FileStream(java.lang.String path,
FileMode mode,
java.util.EnumSet<FileAccess> access)
When it is called by trusted applications, initializes a new instance of the System.IO.FileStream class with the specified path, creation mode, and read/write permission.
|
|
FileStream(java.lang.String path,
FileMode mode,
java.util.EnumSet<FileAccess> access,
java.util.EnumSet<FileShare> share) |
|
FileStream(java.lang.String path,
FileMode mode,
java.util.EnumSet<FileAccess> access,
java.util.EnumSet<FileShare> share,
int bufferSize) |
Modifier and Type | Method and Description |
---|---|
boolean |
CanRead()
When overridden in a derived class, gets a value indicating whether the current stream supports reading.
|
boolean |
CanSeek()
When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
|
boolean |
CanWrite()
When overridden in a derived class, gets a value indicating whether the current stream supports writing.
|
protected void |
finalize()
Ensures that resources are freed and other cleanup operations are performed when the garbage collector reclaims the FileStream.
|
void |
Flush()
When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
|
java.lang.String |
getName() |
long |
getPosition()
When overridden in a derived class, gets the position within the current stream.
|
long |
Length()
When overridden in a derived class, gets the length in bytes of the stream.
|
int |
Read(byte[] buffer,
int offset,
int count)
When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
|
long |
Seek(long offset,
SeekOrigin origin)
When overridden in a derived class, sets the position within the current stream.
|
void |
SetLength(long value)
When overridden in a derived class, sets the length of the current stream.
|
void |
setPosition(long value)
When overridden in a derived class, sets the position within the current stream.
|
void |
Write(byte[] buffer,
int offset,
int count)
When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
|
protected FileStream()
public FileStream(java.lang.String path, FileMode mode)
path
- A relative or absolute path for the file that the current FileStream object will encapsulate.mode
- A System.IO.FileMode constant that determines how to open or create the file.ArgumentException
- path is an empty string (""), contains only white space, or contains one or more invalid characters. -or-path refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in an NTFS environment.NotSupportedException
- path refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in a non-NTFS environment.ArgumentNullException
- path is null.System.Security.SecurityException
- The caller does not have the required permission.FileNotFoundException
- The file cannot be found, such as when mode is FileMode.Truncate or FileMode.Open, and the file specified by path does not exist. The file must already exist in these modes.IOException
- An I/O error occurs, such as specifying FileMode.CreateNew and the file specified by path already exists.-or-The stream has been closed.PathTooLongException
- The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.public FileStream(java.lang.String path, FileMode mode, java.util.EnumSet<FileAccess> access)
path
- mode
- access
- public FileStream(java.lang.String path, FileMode mode, java.util.EnumSet<FileAccess> access, java.util.EnumSet<FileShare> share)
path
- mode
- access
- share
- public FileStream(java.lang.String path, FileMode mode, java.util.EnumSet<FileAccess> access, java.util.EnumSet<FileShare> share, int bufferSize)
path
- mode
- access
- share
- bufferSize
- public boolean CanRead()
Stream
public boolean CanSeek()
Stream
public boolean CanWrite()
Stream
public long Length()
Stream
public java.lang.String getName()
public long getPosition()
Stream
getPosition
in class Stream
public void setPosition(long value)
Stream
setPosition
in class Stream
value
- The new position within the stream.protected void finalize()
finalize
in class java.lang.Object
public void Flush()
Stream
public int Read(byte[] buffer, int offset, int count)
Stream
Read
in class Stream
buffer
- An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.offset
- The zero-based byte offset in buffer at which to begin storing the data read from the current stream.count
- The maximum number of bytes to be read from the current stream.public long Seek(long offset, SeekOrigin origin)
Stream
public void SetLength(long value)
Stream
public void Write(byte[] buffer, int offset, int count)
Stream
Write
in class Stream
buffer
- offset
- count
- ArgumentNullException
- buffer is null.ArgumentOutOfRangeException