final String id = Utils.readString(raf, 4);
final int size = Utils.readUint32AsInt(raf);
if (size < 8) {
throw new CannotReadException(
"Corrupt file: RealAudio chunk length at position "
+ (raf.getFilePointer() - 4)
+ " cannot be less than 8");
}
if (size > (raf.length() - raf.getFilePointer() + 8)) {
throw new CannotReadException(
"Corrupt file: RealAudio chunk length of " + size
+ " at position " + (raf.getFilePointer() - 4)
+ " extends beyond the end of the file");
}
final byte[] bytes = new byte[size - 8];
raf.readFully(bytes);
return new RealChunk(id, size, bytes);