-
- All Implemented Interfaces:
-
java.io.Closeable,java.io.DataInput,java.io.DataOutput,java.lang.AutoCloseable
public abstract class SuRandomAccessFile implements DataInput, DataOutput, Closeable
Access files using the main shell and mimics RandomAccessFile.
Usage of this class is not recommended. Each I/O operation comes with a large overhead and depends on certain behavior of the command
{@code dd}. Writing to files through shell commands is proven to be error prone. YOU HAVE BEEN WARNED!Please use SuFileInputStream and SuFileOutputStream whenever possible.This class always checks whether using a shell is necessary. If not, it simply opens a new RandomAccessFile and behaves as a wrapper. This class has almost the exact same methods as RandomAccessFile and can be treated as a drop-in replacement.
-
-
Method Summary
Modifier and Type Method Description static SuRandomAccessFileopen(@NonNull() File file, String mode)static SuRandomAccessFileopen(@NonNull() String path, String mode){@code SuRandomAccessFile.open(new File(path), mode)}abstract intread()abstract intread(Array<byte> b)abstract intread(Array<byte> b, int off, int len)abstract voidseek(long pos)abstract voidsetLength(long newLength)abstract longlength()abstract longgetFilePointer()-
Methods inherited from class java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readInt, readLine, readLong, readShort, readUTF, readUnsignedByte, readUnsignedShort, skipBytes -
Methods inherited from class java.io.DataOutput
write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF -
Methods inherited from class java.io.Closeable
close -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
open
@NonNull() static SuRandomAccessFile open(@NonNull() File file, String mode)
- Parameters:
file- the file object.mode- the access mode.
-
open
@NonNull() static SuRandomAccessFile open(@NonNull() String path, String mode)
{@code SuRandomAccessFile.open(new File(path), mode)}
-
read
abstract int read()
-
seek
abstract void seek(long pos)
-
setLength
abstract void setLength(long newLength)
-
length
abstract long length()
-
getFilePointer
abstract long getFilePointer()
-
-
-
-