本文整理了Java中ucar.unidata.io.RandomAccessFile.seek
方法的一些代码示例,展示了RandomAccessFile.seek
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomAccessFile.seek
方法的具体详情如下:
包路径:ucar.unidata.io.RandomAccessFile
类名称:RandomAccessFile
方法名:seek
[英]Set the position in the file for the next read or write.
[中]在文件中设置下一次读取或写入的位置。
代码示例来源:origin: edu.ucar/cdm
/**
* 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);
}
代码示例来源:origin: edu.ucar/netcdf
@Override
public StructureDataIterator reset() {
bytesRead = 0;
recno = 0;
try {
vinfo.raf.seek(0);
} catch (IOException e) {
throw new RuntimeException(e);
}
return this;
}
代码示例来源:origin: edu.ucar/cdm
@Override
public StructureDataIterator reset() {
recno = 0;
try {
vinfo.rafile.seek(0);
} catch (IOException e) {
throw new RuntimeException(e);
}
return this;
}
代码示例来源:origin: edu.ucar/netcdf
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));
}
代码示例来源:origin: edu.ucar/cdm
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;
}
}
代码示例来源:origin: edu.ucar/cdm
void show(RandomAccessFile raf) throws IOException {
raf.seek(filePos);
byte[] b = raf.readBytes(40);
System.out.println(new String(b, CDM.utf8Charset));
}
代码示例来源:origin: edu.ucar/cdm
void read() throws IOException {
raf.seek(offset);
byte[] buff = new byte[length];
raf.readFully(buff);
bb = ByteBuffer.wrap(buff);
}
代码示例来源:origin: Unidata/thredds
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;
}
代码示例来源:origin: edu.ucar/cdm
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);
}
代码示例来源:origin: edu.ucar/cdm
private void skip(int nbytes) throws IOException {
int pad = padding(nbytes);
if (pad > 0)
raf.seek(raf.getFilePointer() + pad);
}
代码示例来源:origin: edu.ucar/cdm
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();
}
}
代码示例来源:origin: Unidata/thredds
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;
}
代码示例来源:origin: Unidata/thredds
public Grib1SectionBitMap(RandomAccessFile raf) throws IOException {
startingPosition = raf.getFilePointer();
// octets 1-3 (Length of section)
int length = GribNumbers.int3(raf);
raf.seek(startingPosition + length);
}
代码示例来源:origin: edu.ucar/cdm
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);
}
代码示例来源:origin: edu.ucar/netcdf
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);
}
代码示例来源:origin: edu.ucar/cdm
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);
}
代码示例来源:origin: Unidata/thredds
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);
}
代码示例来源:origin: edu.ucar/netcdf
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();
}
代码示例来源:origin: edu.ucar/cdm
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();
}
代码示例来源:origin: Unidata/thredds
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();
}
内容来源于网络,如有侵权,请联系作者删除!