Record9() throws IOException { raf.read(heapId); flags = raf.readByte(); creationOrder = raf.readInt(); } }
private long readVariableSizeN(int nbytes) throws IOException { int[] ch = new int[nbytes]; for (int i = 0; i < nbytes; i++) ch[i] = raf.read(); long result = ch[nbytes - 1]; for (int i = nbytes - 2; i >= 0; i--) { result = result << 8; result += ch[i]; } return result; }
Record5() throws IOException { nameHash = raf.readInt(); raf.read(heapId); if (debugBtree2) debugOut.println(" record5 nameHash=" + nameHash + " heapId=" + Misc.showBytes(heapId)); } }
Record6() throws IOException { creationOrder = raf.readLong(); raf.read(heapId); if (debugBtree2) debugOut.println(" record6 creationOrder=" + creationOrder + " heapId=" + Misc.showBytes(heapId)); } }
private long readVariableSizeN(int nbytes) throws IOException { int[] ch = new int[nbytes]; for (int i = 0; i < nbytes; i++) ch[i] = raf.read(); long result = ch[nbytes - 1]; for (int i = nbytes - 2; i >= 0; i--) { result = result << 8; result += ch[i]; } return result; }
/** * Read a String of known length. * * @param size number of bytes * @return String result * @throws java.io.IOException on io error */ private String readStringFixedLength(int size) throws IOException { byte[] s = new byte[size]; raf.read(s); return new String(s, CDM.utf8Charset); // all Strings are UTF-8 unicode }
private String readString(int len) throws IOException { if (len < 0) System.out.println("what"); byte[] b = new byte[len]; raf.read(b); int count; for (count = 0; count < len; count++) if (b[count] == 0) break; return new String(b, 0, count, CDM.utf8Charset); }
static public boolean isValidFile(ucar.unidata.io.RandomAccessFile raf) throws IOException { // this is the first time we try to read the file - if there's a problem we get a IOException raf.seek(0); byte[] b = new byte[4]; raf.read(b); for (int i = 0; i < 3; i++) if (b[i] != MAGIC[i]) return false; return ((b[3] == 1) || (b[3] == 2)); }
public final byte[] getOptiondsalSection(RandomAccessFile raf) throws IOException { if (!hasOptionalSection) return null; byte[] optionalSection = new byte[optionalSectionLen - 4]; raf.seek(optionalSectionPos); int nRead = raf.read(optionalSection); if (nRead != optionalSection.length) log.warn("Error reading optional section -- expected " + optionalSection.length + " but read " + nRead); return optionalSection; }
public final byte[] getOptionalSection(RandomAccessFile raf) throws IOException { if (!hasOptionalSection) return null; byte[] optionalSection = new byte[optionalSectionLen - 4]; raf.seek(optionalSectionPos); raf.read(optionalSection); return optionalSection; }
private boolean readAndTest(RandomAccessFile raf, byte[] test) throws IOException { byte[] b = new byte[test.length]; raf.read(b); return test(b, test); }
public Grib2SectionBitMap(RandomAccessFile raf) throws IOException { startingPosition = raf.getFilePointer(); // octets 1-4 (Length of section) int length = GribNumbers.int4(raf); // octet 5 int section = raf.read(); if (section != 6) throw new IllegalArgumentException("Not a GRIB-2 Bitmap section"); // octet 6 bitMapIndicator = raf.read(); raf.seek(startingPosition + length); }
/** * Constructs a <tt>BufrIndicatorSection</tt> object from a raf. * * @param raf RandomAccessFile with IndicatorSection content * @throws IOException on read error */ public BufrIndicatorSection(RandomAccessFile raf) throws IOException { this.startPos = raf.getFilePointer() - 4; // start of BUFR message, including "BUFR" bufrLength = BufrNumbers.uint3(raf); edition = raf.read(); }
public Grib2SectionData(RandomAccessFile raf) throws IOException { startingPosition = raf.getFilePointer(); // octets 1-4 (Length of section) msgLength = GribNumbers.int4(raf); // octet 5 int section = raf.read(); if (section != 7) throw new IllegalStateException("Not a Grib2SectionData (section 7)"); // skip to end of the data section raf.seek(startingPosition + msgLength); }
void dump(String head, long filePos, int nbytes, boolean count) throws IOException { long savePos = raf.getFilePointer(); if (filePos >= 0) raf.seek(filePos); byte[] mess = new byte[nbytes]; raf.read(mess); printBytes(head, mess, nbytes, false, debugOut); raf.seek(savePos); }