本文整理了Java中ucar.unidata.io.RandomAccessFile.read
方法的一些代码示例,展示了RandomAccessFile.read
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomAccessFile.read
方法的具体详情如下:
包路径:ucar.unidata.io.RandomAccessFile
类名称:RandomAccessFile
方法名:read
[英]Read a byte of data from the file, blocking until data is available.
[中]从文件中读取一个字节的数据,直到数据可用为止。
代码示例来源:origin: edu.ucar/netcdf
Record9() throws IOException {
raf.read(heapId);
flags = raf.readByte();
creationOrder = raf.readInt();
}
}
代码示例来源:origin: edu.ucar/cdm
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;
}
代码示例来源:origin: edu.ucar/netcdf
Record5() throws IOException {
nameHash = raf.readInt();
raf.read(heapId);
if (debugBtree2)
debugOut.println(" record5 nameHash=" + nameHash + " heapId=" + Misc.showBytes(heapId));
}
}
代码示例来源:origin: edu.ucar/netcdf
Record6() throws IOException {
creationOrder = raf.readLong();
raf.read(heapId);
if (debugBtree2)
debugOut.println(" record6 creationOrder=" + creationOrder + " heapId=" + Misc.showBytes(heapId));
}
}
代码示例来源:origin: Unidata/thredds
Type40(RandomAccessFile raf) throws IOException {
super(raf);
this.compressionMethod = raf.read();
this.compressionRatio = raf.read();
}
代码示例来源:origin: edu.ucar/netcdf
private int readVInt(RandomAccessFile raf) throws IOException {
byte b = (byte) raf.read();
int i = b & 0x7F;
for (int shift = 7; (b & 0x80) != 0; shift += 7) {
b = (byte) raf.read();
i |= (b & 0x7F) << shift;
}
return i;
}
代码示例来源:origin: Unidata/thredds
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;
}
代码示例来源:origin: edu.ucar/netcdf
/**
* 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
}
代码示例来源:origin: Unidata/thredds
/**
* Convert 2 bytes into a signed integer.
*
* @param raf
* @return integer value
* @throws IOException
*/
public static int int2(RandomAccessFile raf) throws IOException {
int a = raf.read();
int b = raf.read();
return int2(a, b);
}
代码示例来源:origin: Unidata/thredds
/**
* Convert 2 bytes into an unsigned integer.
*
* @param raf
* @return integer value
* @throws IOException
*/
public static int uint2(RandomAccessFile raf) throws IOException {
int a = raf.read();
int b = raf.read();
return uint2(a, b);
}
代码示例来源:origin: Unidata/thredds
/**
* Convert 2 bytes into an unsigned integer.
*
* @param raf read from here
* @return integer value
* @throws IOException on read error
*/
public static int uint2(RandomAccessFile raf) throws IOException {
int a = raf.read();
int b = raf.read();
return uint2(a, b);
}
代码示例来源:origin: edu.ucar/netcdf
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);
}
代码示例来源: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: 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/bufr
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;
}
代码示例来源:origin: edu.ucar/netcdf
private boolean readAndTest(RandomAccessFile raf, byte[] test) throws IOException {
byte[] b = new byte[test.length];
raf.read(b);
return test(b, test);
}
代码示例来源:origin: Unidata/thredds
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);
}
代码示例来源:origin: Unidata/thredds
/**
* 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();
}
代码示例来源:origin: Unidata/thredds
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);
}
代码示例来源:origin: edu.ucar/netcdf
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);
}
内容来源于网络,如有侵权,请联系作者删除!