java.io.Closeable
, java.io.DataInput
, java.io.DataOutput
, java.lang.AutoCloseable
, java.nio.channels.ByteChannel
, java.nio.channels.Channel
, java.nio.channels.ReadableByteChannel
, java.nio.channels.SeekableByteChannel
, java.nio.channels.WritableByteChannel
public class BufferedRandomAccessFile extends FileAccess
RandomAccessFile
. Diese Klasse implementiert die Interfaces
DataInput
, DataOutput
und ByteChannel
und unterstützt
alle wesentlichen Methoden eines RandomAccessFile
s
Diese Klasse ist (anders als FileChannel
) nicht für die Verwendung durch mehrere unsynchronisierte
Threads geeignet.Modifier and Type | Field | Description |
---|---|---|
protected java.io.InputStream |
_rawInStream |
ungepufferter EingabeStream
|
protected java.io.OutputStream |
_rawOutStream |
ungepufferter AusgabeStream
|
_bufferSize, _dataInStream, _dataOutStream, _position, defaultBufferSize
Constructor | Description |
---|---|
BufferedRandomAccessFile(java.io.File file) |
Erstellt ein neues gepuffertes BufferedFile als gepufferten Ersatz eines
RandomAccessFile . |
BufferedRandomAccessFile(java.io.File file,
int bufferSize) |
Erstellt ein neues gepuffertes BufferedFile als gepufferten Ersatz eines
RandomAccessFile . |
BufferedRandomAccessFile(java.io.File file,
java.lang.String mode) |
Erstellt ein neues gepuffertes BufferedFile als gepufferten Ersatz eines
RandomAccessFile . |
BufferedRandomAccessFile(java.io.File file,
java.lang.String mode,
int bufferSize) |
Erstellt ein neues gepuffertes BufferedFile als gepufferten Ersatz eines
RandomAccessFile . |
Modifier and Type | Method | Description |
---|---|---|
java.nio.channels.FileChannel |
getChannel() |
Gibt einen gültigen FileChannel zurück, mit dem die Klasse die Datei manipulieren kann.
|
protected java.io.DataInputStream |
getDataInStream() |
Gibt einen DataInputStream zum Lesen zurück
|
protected java.io.DataOutputStream |
getDataOutStream() |
Gibt einen DataOutputStream zum Schreiben zurück
|
boolean |
isOpen() |
|
BufferedRandomAccessFile |
position(long newPosition) |
|
BufferedRandomAccessFile |
truncate(long size) |
close, flush, flushInStream, flushOutStream, getFilePointer, length, position, read, read, read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seek, setLength, size, skip, skipBytes, toString, write, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
protected final java.io.InputStream _rawInStream
protected final java.io.OutputStream _rawOutStream
public BufferedRandomAccessFile(java.io.File file) throws java.io.FileNotFoundException
RandomAccessFile
.file
- Dateijava.io.FileNotFoundException
- Falls Datei nicht gefundenpublic BufferedRandomAccessFile(java.io.File file, int bufferSize) throws java.io.FileNotFoundException
RandomAccessFile
.file
- DateibufferSize
- Größe des Lese und Schreibpuffers in Bytejava.io.FileNotFoundException
- Falls Datei nicht gefundenpublic BufferedRandomAccessFile(java.io.File file, java.lang.String mode) throws java.io.FileNotFoundException
RandomAccessFile
.file
- Dateimode
- "r" wenn nur gelesen werden soll, "rw" zum Lesen und schreiben. Siehe RandomAccessFile
java.io.FileNotFoundException
- Falls Datei nicht gefundenpublic BufferedRandomAccessFile(java.io.File file, java.lang.String mode, int bufferSize) throws java.io.FileNotFoundException
RandomAccessFile
.file
- Dateimode
- "r" wenn nur gelesen werden soll, "rw" zum Lesen und schreiben. Siehe RandomAccessFile
bufferSize
- Größe des Lese und Schreibpuffers in Bytejava.io.FileNotFoundException
- Falls Datei nicht gefundenprotected java.io.DataOutputStream getDataOutStream()
FileAccess
getDataOutStream
in class FileAccess
protected java.io.DataInputStream getDataInStream() throws java.io.IOException
FileAccess
getDataInStream
in class FileAccess
java.io.IOException
public boolean isOpen()
isOpen
in interface java.nio.channels.Channel
isOpen
in class FileAccess
public java.nio.channels.FileChannel getChannel()
FileAccess
getChannel
in class FileAccess
public BufferedRandomAccessFile position(long newPosition) throws java.io.IOException
position
in interface java.nio.channels.SeekableByteChannel
position
in class FileAccess
java.io.IOException
FileChannel.position(long)
public BufferedRandomAccessFile truncate(long size) throws java.io.IOException
truncate
in interface java.nio.channels.SeekableByteChannel
truncate
in class FileAccess
java.io.IOException
FileChannel.truncate(long)