/** * Constructor * * @param raf the RandomAccessFile * @param startPos points to start of data in data section, in bytes * @throws IOException on read error */ public BitReader(RandomAccessFile raf, long startPos) throws IOException { this.raf = raf; this.startPos = startPos; raf.seek(startPos); }
@Override public StructureDataIterator reset() { bytesRead = 0; recno = 0; try { vinfo.raf.seek(0); } catch (IOException e) { throw new RuntimeException(e); } return this; }
@Override public StructureDataIterator reset() { recno = 0; try { vinfo.rafile.seek(0); } catch (IOException e) { throw new RuntimeException(e); } return this; }
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 boolean isValidFile( RandomAccessFile raf) throws IOException { try { raf.seek(0); String test = raf.readString(8); return test.equals( Level2VolumeScan.ARCHIVE2) || test.equals( Level2VolumeScan.AR2V0001) || test.equals( Level2VolumeScan.AR2V0003)|| test.equals( Level2VolumeScan.AR2V0004) || test.equals( Level2VolumeScan.AR2V0002) || test.equals( Level2VolumeScan.AR2V0006) || test.equals( Level2VolumeScan.AR2V0007); } catch (IOException ioe) { return false; } }
void show(RandomAccessFile raf) throws IOException { raf.seek(filePos); byte[] b = raf.readBytes(40); System.out.println(new String(b, CDM.utf8Charset)); }
void read() throws IOException { raf.seek(offset); byte[] buff = new byte[length]; raf.readFully(buff); bb = ByteBuffer.wrap(buff); }
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; }
private void skip(int nbytes) throws IOException { int pad = padding(nbytes); if (pad > 0) raf.seek(raf.getFilePointer() + pad); }
void read() throws IOException { raf.seek(offset); nelems = length / 4; elem_tag = new short[nelems]; elem_ref = new short[nelems]; for (int i = 0; i < nelems; i++) { elem_tag[i] = raf.readShort(); elem_ref[i] = raf.readShort(); } }
static boolean validatePIB(ucar.unidata.io.RandomAccessFile raf) throws IOException { int pos = 0; raf.seek(pos); // gini header process String pib = raf.readString(GINI_PIB_LEN + GINI_HED_LEN); return findWMOHeader(pib) != 0; }
public Grib1SectionBitMap(RandomAccessFile raf) throws IOException { startingPosition = raf.getFilePointer(); // octets 1-3 (Length of section) int length = GribNumbers.int3(raf); raf.seek(startingPosition + length); }
HeapIdentifier(long address) throws IOException { // header information is in le byte order raf.order(RandomAccessFile.LITTLE_ENDIAN); raf.seek(address); nelems = raf.readInt(); heapAddress = readOffset(); index = raf.readInt(); if (debugDetail) debugOut.println(" read HeapIdentifier address=" + address + this); if (debugHeap) dump("heapIdentifier", getFileOffset(address), 16, true); }
Object readDoubleArray1D(int offsetInRecord) throws IOException { int elementSizeInBytes = 8; double[] array = new double[header.getNumDataRecords()]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.readDouble(array, i, 1); this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes); } return (array); }
Object readFloatArray1D(int offsetInRecord) throws IOException { int elementSizeInBytes = 4; float[] array = new float[header.getNumDataRecords()]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.readFloat(array, i, 1); this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes); } return (array); }
Object readFloatArray1D(int offsetInRecord) throws IOException { int elementSizeInBytes = 4; float[] array = new float[header.getNumDataRecords()]; this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord); for (int i = 0; i < header.getNumDataRecords(); i++) { this.raf.readFloat(array, i, 1); this.raf.skipBytes(header.getRecordSizeInBytes() - elementSizeInBytes); } return (array); }
void read() throws IOException { raf.seek(offset); xdim = raf.readInt(); ydim = raf.readInt(); raf.skipBytes(2); nt_ref = raf.readShort(); nelems = raf.readShort(); interlace = raf.readShort(); compress = raf.readShort(); compress_ref = raf.readShort(); }
void read() throws IOException { raf.seek(offset); xdim = raf.readInt(); ydim = raf.readInt(); raf.skipBytes(2); nt_ref = raf.readShort(); nelems = raf.readShort(); interlace = raf.readShort(); compress = raf.readShort(); compress_ref = raf.readShort(); }
protected void read() throws IOException { raf.seek(offset); xdim = raf.readInt(); ydim = raf.readInt(); raf.skipBytes(2); nt_ref = raf.readShort(); nelems = raf.readShort(); interlace = raf.readShort(); compress = raf.readShort(); compress_ref = raf.readShort(); }