List of utility methods to do RandomAccessFile Read
String | readFromFile(final String path) Reads a file into a string. final RandomAccessFile access = new RandomAccessFile(path, "r"); final StringBuffer result = new StringBuffer(); try { while (access.getFilePointer() < access.length()) { result.append(access.readLine() + "\n"); } finally { access.close(); ... |
void | writeIntLittleEndian(RandomAccessFile file, int value) write Int Little Endian int a = value & 0xFF; int b = (value >> 8) & 0xFF; int c = (value >> 16) & 0xFF; int d = (value >> 24) & 0xFF; file.writeByte(a); file.writeByte(b); file.writeByte(c); file.writeByte(d); ... |
String | readString(RandomAccessFile file, int size) read String int lastNonNullChar = 0; StringBuilder builder = new StringBuilder(size); for (int i = 0; i < size; i++) { int c = file.read(); if (c != 0) { lastNonNullChar = i; builder.append((char) c); ... |
void | fillPadding(RandomAccessFile file, int size) fill Padding if (size < 0) { throw new IOException(String.format("Negative padding: %d", size)); for (int i = 0; i < size; i++) { file.writeByte(0); |
int | readIntLittleEndian(RandomAccessFile file) read Int Little Endian int a = file.readByte() & 0xFF; int b = file.readByte() & 0xFF; int c = file.readByte() & 0xFF; int d = file.readByte() & 0xFF; int res = (d << 24) | (c << 16) | (b << 8) | a; return res; |
int | readBSInt(RandomAccessFile is) read BS Int int i1 = is.read(); int i2 = is.read(); int i3 = is.read(); int i4 = is.read(); i1 = ((((i1) >= 0) ? (i1) : (256 + i1))); i2 = ((((i2) >= 0) ? (i2) : (256 + i2))); i3 = ((((i3) >= 0) ? (i3) : (256 + i3))); i4 = ((((i4) >= 0) ? (i4) : (256 + i4))); ... |
short | readBSShort(RandomAccessFile is) read BS Short int i1 = is.read(); int i2 = is.read(); i1 = ((((i1) >= 0) ? (i1) : (256 + i1))); i2 = ((((i2) >= 0) ? (i2) : (256 + i2))); return (short) (i1 + (i2 << 8)); |
short | readShort(RandomAccessFile is) read Short int i1 = is.read(); int i2 = is.read(); return (short) ((i1 << 8) + i2); |