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.WritableByteChannelBufferedRandomAccessFile, CloseableRandomAccessFilepublic abstract class FileAccess
extends java.lang.Object
implements java.io.DataInput, java.io.DataOutput, java.nio.channels.SeekableByteChannel
| Modifier and Type | Field | Description |
|---|---|---|
protected int |
_bufferSize |
Größe des Lese und Schreibpuffers
|
protected java.io.DataInputStream |
_dataInStream |
Gepufferter EingabeStream, wird bei Bedarf initialisiert und gelöscht
|
protected java.io.DataOutputStream |
_dataOutStream |
Gepufferter AusgabeStream, wird bei Bedarf initialisiert und gelöscht
|
protected long |
_position |
Aktuelle Dateiposition aus Anwendersicht, muss hier gemerkt und selbst berechnet werden, weil die Position des FileChannels durch die
Pufferung beim Lesen und Schreiben nicht notwendigerweise der aktuellen logischen Position entspricht
|
protected static int |
defaultBufferSize |
Standardpuffergröße
|
| Constructor | Description |
|---|---|
FileAccess(int bufferSize) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
|
void |
flush() |
Schreibt den Schreibpuffer auf die Festplatte
|
protected void |
flushInStream() |
|
protected void |
flushOutStream() |
|
protected abstract java.nio.channels.FileChannel |
getChannel() |
Gibt einen gültigen FileChannel zurück, mit dem die Klasse die Datei manipulieren kann.
|
protected abstract java.io.DataInputStream |
getDataInStream() |
Gibt einen DataInputStream zum Lesen zurück
|
protected abstract java.io.DataOutputStream |
getDataOutStream() |
Gibt einen DataOutputStream zum Schreiben zurück
|
long |
getFilePointer() |
Für RandomAccessFile-Kompatibilität
|
abstract boolean |
isOpen() |
|
long |
length() |
Für RandomAccessFile-Kompatibilität
|
long |
position() |
|
FileAccess |
position(long newPosition) |
|
int |
read() |
Deprecated.
|
int |
read(byte[] b) |
Methode analog zu
RandomAccessFile.read(byte[]). |
int |
read(byte[] b,
int off,
int len) |
Methode analog zu
RandomAccessFile.read(byte[], int, int). |
int |
read(java.nio.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() |
|
java.lang.String |
readLine() |
Deprecated.
|
long |
readLong() |
|
short |
readShort() |
|
int |
readUnsignedByte() |
|
int |
readUnsignedShort() |
|
java.lang.String |
readUTF() |
|
void |
seek(long position) |
Für RandomAccessFile-Kompatibilität
|
void |
setLength(long len) |
Für RandomAccessFile-Kompatibilität
|
long |
size() |
Gibt die Dateilänge zurück
|
long |
skip(long n) |
Überspringt genau n Bytes.
|
int |
skipBytes(int n) |
Überspringt n genau Bytes.
|
java.lang.String |
toString() |
|
FileAccess |
truncate(long size) |
|
void |
write(byte[] b) |
|
void |
write(byte[] b,
int off,
int len) |
|
void |
write(int b) |
|
int |
write(java.nio.ByteBuffer src) |
|
void |
writeBoolean(boolean v) |
|
void |
writeByte(int v) |
|
void |
writeBytes(java.lang.String s) |
|
void |
writeChar(int v) |
|
void |
writeChars(java.lang.String s) |
|
void |
writeDouble(double v) |
|
void |
writeFloat(float v) |
|
void |
writeInt(int v) |
|
void |
writeLong(long v) |
|
void |
writeShort(int v) |
|
void |
writeUTF(java.lang.String s) |
protected static final int defaultBufferSize
protected final int _bufferSize
protected java.io.DataInputStream _dataInStream
protected java.io.DataOutputStream _dataOutStream
protected long _position
protected void flushInStream()
protected void flushOutStream()
throws java.io.IOException
java.io.IOExceptionprotected abstract java.io.DataOutputStream getDataOutStream()
throws java.io.IOException
java.io.IOExceptionprotected abstract java.io.DataInputStream getDataInStream()
throws java.io.IOException
java.io.IOExceptionprotected abstract java.nio.channels.FileChannel getChannel()
throws java.io.IOException
java.io.IOExceptionpublic abstract boolean isOpen()
isOpen in interface java.nio.channels.Channelpublic void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channelclose in interface java.io.Closeablejava.io.IOExceptionpublic void readFully(byte[] b)
throws java.io.IOException
readFully in interface java.io.DataInputjava.io.IOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws java.io.IOException
readFully in interface java.io.DataInputjava.io.IOExceptionpublic int skipBytes(int n)
throws java.io.IOException
position(position() + n); return n;
Diese Methode kann über das Dateiende hinausspringen, vgl. RandomAccessFile.seek(long).skipBytes in interface java.io.DataInputn - Anzahl zu überspringender Bytes (kann negativ sein, dann wird rückwärts gesprungen)java.io.IOException - Eingabe-/Ausgabefehler beim Lesen oder Schreiben der Dateipublic long skip(long n)
throws java.io.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)java.io.IOException - Eingabe-/Ausgabefehler beim Lesen oder Schreiben der Dateipublic boolean readBoolean()
throws java.io.IOException
readBoolean in interface java.io.DataInputjava.io.IOExceptionpublic byte readByte()
throws java.io.IOException
readByte in interface java.io.DataInputjava.io.IOExceptionpublic int readUnsignedByte()
throws java.io.IOException
readUnsignedByte in interface java.io.DataInputjava.io.IOExceptionpublic short readShort()
throws java.io.IOException
readShort in interface java.io.DataInputjava.io.IOExceptionpublic int readUnsignedShort()
throws java.io.IOException
readUnsignedShort in interface java.io.DataInputjava.io.IOExceptionpublic char readChar()
throws java.io.IOException
readChar in interface java.io.DataInputjava.io.IOExceptionpublic int readInt()
throws java.io.IOException
readInt in interface java.io.DataInputjava.io.IOExceptionpublic long readLong()
throws java.io.IOException
readLong in interface java.io.DataInputjava.io.IOExceptionpublic float readFloat()
throws java.io.IOException
readFloat in interface java.io.DataInputjava.io.IOExceptionpublic double readDouble()
throws java.io.IOException
readDouble in interface java.io.DataInputjava.io.IOException@Deprecated public java.lang.String readLine()
readLine in interface java.io.DataInputjava.lang.UnsupportedOperationException - immerpublic java.lang.String readUTF()
throws java.io.IOException
readUTF in interface java.io.DataInputjava.io.IOExceptionpublic void write(int b)
throws java.io.IOException
write in interface java.io.DataOutputjava.io.IOExceptionpublic void write(byte[] b)
throws java.io.IOException
write in interface java.io.DataOutputjava.io.IOExceptionpublic void write(byte[] b,
int off,
int len)
throws java.io.IOException
write in interface java.io.DataOutputjava.io.IOExceptionpublic void writeBoolean(boolean v)
throws java.io.IOException
writeBoolean in interface java.io.DataOutputjava.io.IOExceptionpublic void writeByte(int v)
throws java.io.IOException
writeByte in interface java.io.DataOutputjava.io.IOExceptionpublic void writeShort(int v)
throws java.io.IOException
writeShort in interface java.io.DataOutputjava.io.IOExceptionpublic void writeChar(int v)
throws java.io.IOException
writeChar in interface java.io.DataOutputjava.io.IOExceptionpublic void writeInt(int v)
throws java.io.IOException
writeInt in interface java.io.DataOutputjava.io.IOExceptionpublic void writeLong(long v)
throws java.io.IOException
writeLong in interface java.io.DataOutputjava.io.IOExceptionpublic void writeFloat(float v)
throws java.io.IOException
writeFloat in interface java.io.DataOutputjava.io.IOExceptionpublic void writeDouble(double v)
throws java.io.IOException
writeDouble in interface java.io.DataOutputjava.io.IOExceptionpublic void writeBytes(java.lang.String s)
throws java.io.IOException
writeBytes in interface java.io.DataOutputjava.io.IOExceptionpublic void writeChars(java.lang.String s)
throws java.io.IOException
writeChars in interface java.io.DataOutputjava.io.IOExceptionpublic void writeUTF(java.lang.String s)
throws java.io.IOException
writeUTF in interface java.io.DataOutputjava.io.IOExceptionpublic int read(java.nio.ByteBuffer dst)
throws java.io.IOException
read in interface java.nio.channels.ReadableByteChannelread in interface java.nio.channels.SeekableByteChanneljava.io.IOExceptionpublic int read(byte[] b)
throws java.io.IOException
RandomAccessFile.read(byte[]). Sollte nicht benutzt werden, sie fehleranfällig ist falls nicht der ganze Puffer gelesen wird.
Besser: readFully(byte[])b - Pufferjava.io.IOException - Eingabe-/Ausgabefehler beim Lesen oder Schreiben der Dateipublic int read(byte[] b,
int off,
int len)
throws java.io.IOException
RandomAccessFile.read(byte[], int, int). Sollte nicht benutzt werden, sie fehleranfällig ist falls nicht der ganze Puffer gelesen wird.
Besser: readFully(byte[], int, int)b - Pufferoff - Position im Puffer an die die Daten geschrieben werdenlen - Maximalanzahl zu lesender Bytesjava.io.IOException - Eingabe-/Ausgabefehler beim Lesen oder Schreiben der Datei@Deprecated
public int read()
throws java.io.IOException
RandomAccessFile.read(). Sollte nicht benutzt werden, da fehleranfällig bei Dateiende.
Besser: readByte()java.io.IOException - Eingabe-/Ausgabefehler beim Lesen oder Schreiben der Dateipublic int write(java.nio.ByteBuffer src)
throws java.io.IOException
write in interface java.nio.channels.SeekableByteChannelwrite in interface java.nio.channels.WritableByteChanneljava.io.IOExceptionpublic long position()
position in interface java.nio.channels.SeekableByteChannelFileChannel.position()public FileAccess position(long newPosition) throws java.io.IOException
position in interface java.nio.channels.SeekableByteChanneljava.io.IOExceptionFileChannel.position(long)public FileAccess truncate(long size) throws java.io.IOException
truncate in interface java.nio.channels.SeekableByteChanneljava.io.IOExceptionFileChannel.truncate(long)public long size()
throws java.io.IOException
size in interface java.nio.channels.SeekableByteChanneljava.io.IOExceptionFileChannel.size()public void seek(long position)
throws java.io.IOException
position - Neue Positionjava.io.IOExceptionposition(long),
RandomAccessFile.seek(long)public long getFilePointer()
position(),
RandomAccessFile.getFilePointer()public long length()
throws java.io.IOException
java.io.IOExceptionsize(),
RandomAccessFile.length()public void setLength(long len)
throws java.io.IOException
len - neue Dateilängejava.io.IOExceptionRandomAccessFile.setLength(long)public void flush()
throws java.io.IOException
java.io.IOException - Eingabe-/Ausgabefehler beim Lesen oder Schreiben der Dateipublic java.lang.String toString()
toString in class java.lang.Object