List of utility methods to do RandomAccessFile Write
void | writeString(RandomAccessFile file, int size, String text) write String int textLength = text.length(); int remainingSize = size - textLength; if (remainingSize < 0) { throw new IllegalArgumentException(String.format( "String is too long: '%s' is longer than %d", text, size)); file.writeBytes(text); ... |
void | copyBytes(RandomAccessFile srcFile, RandomAccessFile dstFile, int length, MessageDigest messageDigest) copy Bytes byte[] chunk = new byte[Math.min(length, COPY_CHUNK_SIZE)]; while (length > 0) { int sizeToRead = Math.min(length, COPY_CHUNK_SIZE); int sizeRead = srcFile.read(chunk, 0, sizeToRead); if (sizeRead == -1) { throw new IOException( String.format( "End of source file reached too early. Still %d bytes to read.", ... |