public class BufferedRandomAccessFile extends Object implements DataInput, DataOutput, ByteChannel
RandomAccessFile. Diese Klasse implementiert die Interfaces
DataInput, DataOutput und ByteChannel und unterstützt
alle wesentlichen Methoden eines RandomAccessFiles
Diese Klasse ist (anders als FileChannel) nicht für die Verwendung durch mehrere unsynchronisierte
Threads geeignet.| Constructor and Description |
|---|
BufferedRandomAccessFile(File file)
Erstellt ein neues gepuffertes BufferedFile als gepufferten Ersatz eines
RandomAccessFile. |
BufferedRandomAccessFile(File file,
int bufferSize)
Erstellt ein neues gepuffertes BufferedFile als gepufferten Ersatz eines
RandomAccessFile. |
BufferedRandomAccessFile(File file,
String mode)
Erstellt ein neues gepuffertes BufferedFile als gepufferten Ersatz eines
RandomAccessFile. |
BufferedRandomAccessFile(File file,
String mode,
int bufferSize)
Erstellt ein neues gepuffertes BufferedFile als gepufferten Ersatz eines
RandomAccessFile. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
long |
getFilePointer()
Für RandomAccessFile-Kompatibilität
|
boolean |
isOpen() |
long |
length()
Für RandomAccessFile-Kompatibilität
|
long |
position() |
BufferedRandomAccessFile |
position(long newPosition) |
int |
read(ByteBuffer dst) |
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt() |
String |
readLine()
Deprecated.
|
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
String |
readUTF() |
void |
seek(long position)
Für RandomAccessFile-Kompatibilität
|
void |
setLength(long len)
Für RandomAccessFile-Kompatibilität
|
long |
size() |
long |
skip(long n)
Überspringt n genau Bytes.
|
int |
skipBytes(int n)
Überspringt n genau Bytes.
|
String |
toString() |
BufferedRandomAccessFile |
truncate(long size) |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
int |
write(ByteBuffer src) |
void |
write(int b) |
void |
writeBoolean(boolean v) |
void |
writeByte(int v) |
void |
writeBytes(String s) |
void |
writeChar(int v) |
void |
writeChars(String s) |
void |
writeDouble(double v) |
void |
writeFloat(float v) |
void |
writeInt(int v) |
void |
writeLong(long v) |
void |
writeShort(int v) |
void |
writeUTF(String s) |
public BufferedRandomAccessFile(File file) throws FileNotFoundException
RandomAccessFile.file - DateiFileNotFoundException - Falls Datei nicht gefundenpublic BufferedRandomAccessFile(File file, int bufferSize) throws FileNotFoundException
RandomAccessFile.file - DateibufferSize - Größe des Lese und Schreibpuffers in ByteFileNotFoundException - Falls Datei nicht gefundenpublic BufferedRandomAccessFile(File file, String mode) throws FileNotFoundException
RandomAccessFile.file - Dateimode - "r" wenn nur gelesen werden soll, "rw" zum Lesen und schreiben. Siehe RandomAccessFileFileNotFoundException - Falls Datei nicht gefundenpublic BufferedRandomAccessFile(File file, String mode, int bufferSize) throws FileNotFoundException
RandomAccessFile.file - Dateimode - "r" wenn nur gelesen werden soll, "rw" zum Lesen und schreiben. Siehe RandomAccessFilebufferSize - Größe des Lese und Schreibpuffers in ByteFileNotFoundException - Falls Datei nicht gefundenpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface ChannelIOExceptionpublic void readFully(byte[] b)
throws IOException
readFully in interface DataInputIOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws IOException
readFully in interface DataInputIOExceptionpublic int skipBytes(int n)
throws IOException
position(position() + n); return n;
Diese Methode kann über das Dateiende hinausspringen, vgl. RandomAccessFile.seek(long).skipBytes in interface DataInputn - Anzahl zu überspringender Bytes (kann negativ sein, dann wird rückwärts gesprungen)IOExceptionpublic long skip(long n)
throws IOException
position(position() + n); return n;
Diese Methode kann über das Dateiende hinausspringen, vgl. RandomAccessFile.seek(long).n - Anzahl zu überspringender Bytes (kann negativ sein, dann wird rückwärts gesprungen)IOExceptionpublic boolean readBoolean()
throws IOException
readBoolean in interface DataInputIOExceptionpublic byte readByte()
throws IOException
readByte in interface DataInputIOExceptionpublic int readUnsignedByte()
throws IOException
readUnsignedByte in interface DataInputIOExceptionpublic short readShort()
throws IOException
readShort in interface DataInputIOExceptionpublic int readUnsignedShort()
throws IOException
readUnsignedShort in interface DataInputIOExceptionpublic char readChar()
throws IOException
readChar in interface DataInputIOExceptionpublic int readInt()
throws IOException
readInt in interface DataInputIOExceptionpublic long readLong()
throws IOException
readLong in interface DataInputIOExceptionpublic float readFloat()
throws IOException
readFloat in interface DataInputIOExceptionpublic double readDouble()
throws IOException
readDouble in interface DataInputIOException@Deprecated public String readLine() throws IOException
readLine in interface DataInputIOExceptionpublic String readUTF() throws IOException
readUTF in interface DataInputIOExceptionpublic void write(int b)
throws IOException
write in interface DataOutputIOExceptionpublic void write(byte[] b)
throws IOException
write in interface DataOutputIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in interface DataOutputIOExceptionpublic void writeBoolean(boolean v)
throws IOException
writeBoolean in interface DataOutputIOExceptionpublic void writeByte(int v)
throws IOException
writeByte in interface DataOutputIOExceptionpublic void writeShort(int v)
throws IOException
writeShort in interface DataOutputIOExceptionpublic void writeChar(int v)
throws IOException
writeChar in interface DataOutputIOExceptionpublic void writeInt(int v)
throws IOException
writeInt in interface DataOutputIOExceptionpublic void writeLong(long v)
throws IOException
writeLong in interface DataOutputIOExceptionpublic void writeFloat(float v)
throws IOException
writeFloat in interface DataOutputIOExceptionpublic void writeDouble(double v)
throws IOException
writeDouble in interface DataOutputIOExceptionpublic void writeBytes(String s) throws IOException
writeBytes in interface DataOutputIOExceptionpublic void writeChars(String s) throws IOException
writeChars in interface DataOutputIOExceptionpublic void writeUTF(String s) throws IOException
writeUTF in interface DataOutputIOExceptionpublic int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChannelIOExceptionpublic int write(ByteBuffer src) throws IOException
write in interface WritableByteChannelIOExceptionpublic long position()
FileChannel.position()public BufferedRandomAccessFile position(long newPosition) throws IOException
IOExceptionFileChannel.position(long)public long size()
throws IOException
IOExceptionFileChannel.size()public BufferedRandomAccessFile truncate(long size) throws IOException
IOExceptionFileChannel.truncate(long)public void seek(long position)
throws IOException
IOExceptionposition(long)public long getFilePointer()
position()public long length()
throws IOException
IOExceptionsize()public void setLength(long len)
throws IOException
IOException