本文整理汇总了Java中ucar.unidata.io.RandomAccessFile.skipBytes方法的典型用法代码示例。如果您正苦于以下问题:Java RandomAccessFile.skipBytes方法的具体用法?Java RandomAccessFile.skipBytes怎么用?Java RandomAccessFile.skipBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ucar.unidata.io.RandomAccessFile
的用法示例。
在下文中一共展示了RandomAccessFile.skipBytes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Grib2SectionProductDefinition
import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
* Read Product Definition section from raf.
*
* @param raf RandomAccessFile, with pointer at start of section
* @throws java.io.IOException on I/O error
* @throws IllegalArgumentException if not a GRIB-2 record
*/
public Grib2SectionProductDefinition( RandomAccessFile raf) throws IOException {
long startingPosition = raf.getFilePointer();
// octets 1-4 (Length of GDS)
int length = GribNumbers.int4(raf);
// octet 5
int section = raf.read();
if (section != 4)
throw new IllegalArgumentException("Not a GRIB-2 PDS section");
// octets 8-9
raf.skipBytes(2);
templateNumber = GribNumbers.int2(raf);
// read in whole GDS as byte[]
rawData = new byte[length];
raf.seek(startingPosition);
raf.readFully(rawData);
}
示例2: isValidFile
import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
static public boolean isValidFile(RandomAccessFile raf) {
try {
raf.seek(0);
boolean found = raf.searchForward(matcher, maxScan); // look in first 16K
if (!found)
return false;
raf.skipBytes(7); // will be positioned on byte 0 of indicator section
int edition = raf.read(); // read at byte 8
if (edition != 2)
return false;
// check ending = 7777
long len = GribNumbers.int8(raf);
if (len > raf.length())
return false;
raf.skipBytes(len - 20);
for (int i = 0; i < 4; i++) {
if (raf.read() != 55)
return false;
}
return true;
} catch (IOException e) {
return false;
}
}
示例3: Grib2SectionLocalUse
import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
* Read Grib2SectionLocalUse from raf.
*
* @param raf RandomAccessFile, with pointer at start od section
* @throws java.io.IOException on I/O error
*/
public Grib2SectionLocalUse(RandomAccessFile raf) throws IOException {
// octets 1-4 (Length of GDS)
int length = GribNumbers.int4(raf);
int section = raf.read(); // This is section 2
if (section != 2) { // no local use section
length = 0;
raf.skipBytes(-5);
rawData = null;
return;
} else {
rawData = new byte[length-5];
raf.readFully(rawData);
}
}
示例4: Grib2SectionIndicator
import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
* Read Grib2SectionIndicator from raf.
*
* @param raf RandomAccessFile, with pointer at start (the "GRIB")
* @throws java.io.IOException on I/O error
* @throws IllegalArgumentException if not a GRIB-2 record
*/
public Grib2SectionIndicator(RandomAccessFile raf) throws IOException {
startPos = raf.getFilePointer();
byte[] b = new byte[4];
raf.readFully(b);
// 判断是不是GRIB
for (int i = 0; i < b.length; i++) {
if (b[i] != MAGIC[i])
throw new IllegalArgumentException("Not a GRIB record");
}
raf.skipBytes(2);
discipline = raf.read();
int edition = raf.read();
if (edition != 2)
throw new IllegalArgumentException("Not a GRIB-2 record");
messageLength = GribNumbers.int8(raf);
}
示例5: Grib2SectionGridDefinition
import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
* Read Grib Definition section from raf.
*
* @param raf RandomAccessFile, with pointer at start of section
* @throws java.io.IOException on I/O error
* @throws IllegalArgumentException if not a GRIB-2 record
*/
public Grib2SectionGridDefinition(RandomAccessFile raf) throws IOException {
startingPosition = raf.getFilePointer();
// octets 1-4 (Length of GDS)
int length = GribNumbers.int4(raf);
// octet 5
int section = raf.read(); // This is section 3
if (section != 3)
throw new IllegalArgumentException("Not a GRIB-2 GDS section");
// octets 13-14
raf.skipBytes(7);
templateNumber = GribNumbers.uint2(raf);
// read in whole GDS as byte[]
rawData = new byte[length];
raf.seek(startingPosition);
raf.readFully(rawData);
}
示例6: isValidFile
import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
static public boolean isValidFile(RandomAccessFile raf) {
try {
raf.seek(0);
boolean found = raf.searchForward(matcher, maxScan); // look in first 16K
if (!found) return false;
raf.skipBytes(4); // will be positioned on byte 0 of indicator section
int len = GribNumbers.uint3(raf);
int edition = raf.read(); // read at byte 8
if (edition != 1) return false;
// check ending = 7777
if (len > raf.length()) return false;
if (allowBadIsLength) return true;
raf.skipBytes(len-12);
for (int i = 0; i < 4; i++) {
if (raf.read() != 55) return false;
}
return true;
} catch (IOException e) {
return false;
}
}
示例7: Grib1SectionGridDefinition
import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
* Read Grib Definition section from raf.
*
* @param raf RandomAccessFile, with pointer at start of section
* @throws java.io.IOException on I/O error
* @throws IllegalArgumentException if not a GRIB-2 record
*/
public Grib1SectionGridDefinition(RandomAccessFile raf) throws IOException {
startingPosition = raf.getFilePointer();
// octets 1-3 (Length of GDS)
int length = GribNumbers.int3(raf);
// octet 6
raf.skipBytes(2);
gridTemplate = GribNumbers.uint(raf);
// read in whole GDS as byte[]
rawData = new byte[length];
raf.seek(startingPosition);
raf.readFully(rawData);
predefinedGridDefinition = -1;
predefinedGridDefinitionCenter = -1;
}
示例8: getBitmap
import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
* Read the bit map array.
*
* @param raf read from here
* @return bit map as array of byte values
* @throws java.io.IOException on read error
*/
public byte[] getBitmap(RandomAccessFile raf) throws IOException {
// no bitMap
if (bitMapIndicator == 255)
return null;
// LOOK: bitMapIndicator=254 == previously defined bitmap
if (bitMapIndicator == 254)
// logger.debug("HEY bitMapIndicator=254 previously defined bitmap");
if (bitMapIndicator != 0) {
throw new UnsupportedOperationException("Grib2 Bit map section pre-defined (provided by center) = " + bitMapIndicator);
}
raf.seek(startingPosition);
int length = GribNumbers.int4(raf);
raf.skipBytes(2);
byte[] data = new byte[length - 6];
raf.readFully(data);
return data;
/* create new bit map when it is first asked for
boolean[] bitmap = new boolean[numberOfPoints];
int[] bitmask = {128, 64, 32, 16, 8, 4, 2, 1};
for (int i = 0; i < bitmap.length; i++) {
bitmap[i] = (data[i / 8] & bitmask[i % 8]) != 0;
}
return bitmap; */
}
示例9: Grib1SectionProductDefinition
import ucar.unidata.io.RandomAccessFile; //导入方法依赖的package包/类
/**
* Read Product Definition section from raf.
*
* @param raf RandomAccessFile, with pointer at start of section
* @throws java.io.IOException on I/O error
* @throws IllegalArgumentException if not a GRIB-2 record
*/
public Grib1SectionProductDefinition(RandomAccessFile raf) throws IOException {
int length = GribNumbers.uint3(raf);
rawData = new byte[length];
raf.skipBytes(-3);
raf.readFully(rawData);
}