/** * public by accident, do not use * * @param indexRaf the open raf of the index file */ void setIndexRaf(RandomAccessFile indexRaf) { this.indexRaf = indexRaf; if (indexRaf != null) { this.indexFilename = indexRaf.getLocation(); } }
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)); }
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); }
public static void main(String[] args) throws IOException { int count = 0; RandomAccessFile raf = new RandomAccessFile("Q:/cdmUnitTest/formats/grib2/LMPEF_CLM_050518_1200.grb", "r"); System.out.printf("Read %s%n", raf.getLocation()); Grib2RecordScanner scan = new Grib2RecordScanner(raf); while (scan.hasNext()) { scan.next(); count++; } raf.close(); System.out.printf("count=%d%n",count); }
private static void dump(String filename) throws IOException { System.out.printf("Dump %s%n", filename); RandomAccessFile raf = new RandomAccessFile(filename, "r"); NetcdfFile ncfile = new MyNetcdfFile(); // its a netcdf-3 file raf.order(RandomAccessFile.BIG_ENDIAN); N3header headerParser = new N3header(); headerParser.read(raf, ncfile, new Formatter(System.out)); raf.close(); }
public FileCacheable open(DatasetUrl durl, int buffer_size, CancelTask cancelTask, Object iospMessage) throws IOException { String location = StringUtil2.replace(durl.trueurl, "\\", "/"); // canonicalize the name RandomAccessFile result = new RandomAccessFile(location, "r", buffer_size); result.cacheState = 1; // in use return result; } };
static public boolean isValidFile(RandomAccessFile raf) throws IOException { raf.seek(0); if (!raf.searchForward(matcher, 8000)) return false; // must find "GRIB" in first 8k raf.skipBytes(4); // Read Section 0 Indicator Section to get Edition number Grib2IndicatorSection is = new Grib2IndicatorSection(raf); // section 0 if (is.getGribEdition() != 1 && is.getGribEdition() != 2) return false; if (is.getGribLength() > raf.length()) return false; return true; }
private void skip(int nbytes) throws IOException { int pad = padding(nbytes); if (pad > 0) raf.seek(raf.getFilePointer() + pad); }
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.readFully(mess); printBytes(head, mess, nbytes, false, debugOut); raf.seek(savePos); }
/** * Check if this is a valid SIGMET-IRIS file for this IOServiceProvider. */ public boolean isValidFile(ucar.unidata.io.RandomAccessFile raf) { try { raf.order(RandomAccessFile.LITTLE_ENDIAN); raf.seek(24); return (raf.readShort() == (short) 15); } catch (IOException ioe) { System.out.println("In isValidFile(): " + ioe.toString()); return false; } }
public static void main(String[] args) throws IOException { int count = 0; RandomAccessFile raf = new RandomAccessFile("Q:/cdmUnitTest/formats/grib1/ECMWF.hybrid.grib1", "r"); Grib1RecordScanner scan = new Grib1RecordScanner(raf); while (scan.hasNext()) { scan.next(); count++; } raf.close(); System.out.printf("count=%d%n",count); } }