本文整理了Java中ucar.unidata.io.RandomAccessFile.readFully
方法的一些代码示例,展示了RandomAccessFile.readFully
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomAccessFile.readFully
方法的具体详情如下:
包路径:ucar.unidata.io.RandomAccessFile
类名称:RandomAccessFile
方法名:readFully
[英]Reads b.length
bytes from this file into the byte array. This method reads repeatedly from the file until all the bytes are read. This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.
[中]将b.length
字节从此文件读入字节数组。此方法重复读取文件,直到读取所有字节。此方法会一直阻塞,直到读取所有字节、检测到流结束或引发异常为止。
代码示例来源:origin: Unidata/thredds
static public boolean readAndTest(RandomAccessFile raf, byte[] test) throws IOException {
byte[] b = new byte[test.length];
raf.readFully(b);
if (b.length != test.length) return false;
for (int i = 0; i < b.length; i++)
if (b[i] != test[i]) return false;
return true;
}
代码示例来源:origin: edu.ucar/cdm
static public boolean readAndTest(RandomAccessFile raf, byte[] test) throws IOException {
byte[] b = new byte[test.length];
raf.readFully(b);
if (b.length != test.length) return false;
for (int i = 0; i < b.length; i++)
if (b[i] != test[i]) return false;
return true;
}
代码示例来源:origin: edu.ucar/netcdf
/**
* Read fully count number of bytes
*
* @param count how many bytes tp read
* @return a byte array of length count, fully read in
* @throws IOException if an I/O error occurrs.
*/
public byte[] readBytes(int count) throws IOException {
byte[] b = new byte[count];
readFully(b);
return b;
}
代码示例来源:origin: edu.ucar/cdm
/**
* Read a String of known length.
*
* @param nbytes number of bytes to read
* @return String wrapping the bytes.
* @throws IOException if an I/O error occurs.
*/
public String readString(int nbytes) throws IOException {
byte[] data = new byte[nbytes];
readFully(data);
return new String(data, CDM.utf8Charset);
}
代码示例来源:origin: edu.ucar/netcdf
/**
* Read a String of knoen length.
*
* @param nbytes number of bytes to read
* @return String wrapping the bytes.
* @throws IOException if an I/O error occurs.
*/
public String readString(int nbytes) throws IOException {
byte[] data = new byte[nbytes];
readFully(data);
return new String(data);
}
代码示例来源:origin: edu.ucar/cdm
private boolean readAndTest(RandomAccessFile raf, byte[] test) throws IOException {
byte[] b = new byte[test.length];
raf.readFully(b);
return test(b, test);
}
代码示例来源:origin: edu.ucar/cdm
void read() throws IOException {
raf.seek(offset);
byte[] buff = new byte[length];
raf.readFully(buff);
bb = ByteBuffer.wrap(buff);
}
代码示例来源:origin: edu.ucar/netcdf
private InputStream getCompressedInputStream(H4header.Vinfo vinfo) throws IOException {
// probably could construct an input stream from a channel from a raf
// for now, just read it in.
//System.out.println(" read "+ vinfo.length+" from "+ vinfo.start);
byte[] buffer = new byte[vinfo.length];
raf.seek(vinfo.start);
raf.readFully(buffer);
ByteArrayInputStream in = new ByteArrayInputStream(buffer);
return new java.util.zip.InflaterInputStream(in);
}
代码示例来源:origin: Unidata/thredds
private InputStream getCompressedInputStream(H4header.Vinfo vinfo) throws IOException {
// probably could construct an input stream from a channel from a raf
// for now, just read it in.
//System.out.println(" read "+ vinfo.length+" from "+ vinfo.start);
byte[] buffer = new byte[vinfo.length];
raf.seek(vinfo.start);
raf.readFully(buffer);
ByteArrayInputStream in = new ByteArrayInputStream(buffer);
return new java.util.zip.InflaterInputStream(in);
}
代码示例来源:origin: Unidata/thredds
void read() throws IOException {
size = raf.readInt();
value = new byte[size];
raf.readFully(value);
if (debug1) {
log.debug("{}", this);
}
}
代码示例来源:origin: Unidata/thredds
Record6() throws IOException {
creationOrder = raf.readLong();
raf.readFully(heapId);
if (debugBtree2)
debugOut.println(" record6 creationOrder=" + creationOrder + " heapId=" + Misc.showBytes(heapId));
}
}
代码示例来源:origin: edu.ucar/cdm
Record6() throws IOException {
creationOrder = raf.readLong();
raf.readFully(heapId);
if (debugBtree2)
debugOut.println(" record6 creationOrder=" + creationOrder + " heapId=" + Misc.showBytes(heapId));
}
}
代码示例来源:origin: edu.ucar/cdm
Record70() throws IOException {
location = raf.readByte();
refCount = raf.readInt();
raf.readFully(id);
}
}
代码示例来源:origin: edu.ucar/cdm
Record9() throws IOException {
raf.readFully(heapId);
flags = raf.readByte();
creationOrder = raf.readInt();
}
}
代码示例来源:origin: Unidata/thredds
public byte[] getMessageBytesFromLast(Message m) throws IOException {
long startPos = m.getStartPos();
int length = (int) (lastPos - startPos);
byte[] result = new byte[length];
raf.seek(startPos);
raf.readFully(result);
return result;
}
代码示例来源:origin: Unidata/thredds
Record70() throws IOException {
location = raf.readByte();
refCount = raf.readInt();
raf.readFully(id);
}
}
代码示例来源:origin: Unidata/thredds
public byte[] getData(int offset) throws IOException {
int readLen = (int) raf.length();
byte[] b = new byte[readLen];
int pos = 0;
raf.seek(pos);
raf.readFully(b);
return b;
}
代码示例来源:origin: edu.ucar/cdm
Record8() throws IOException {
raf.readFully(heapId);
flags = raf.readByte();
creationOrder = raf.readInt();
nameHash = raf.readInt();
if (debugBtree2)
debugOut.println(" record8 creationOrder=" + creationOrder + " heapId=" + Misc.showBytes(heapId));
}
}
代码示例来源: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: Unidata/thredds
Object readByteArray2D(int offsetInRecord, int numElementsInRecord) throws IOException {
byte[] array = new byte[header.getNumDataRecords() * numElementsInRecord];
this.raf.seek(header.getRecordSizeInBytes() * header.getNumHeaderRecords() + offsetInRecord);
for (int i = 0; i < header.getNumDataRecords(); i++) {
this.raf.readFully(array, i * numElementsInRecord, numElementsInRecord);
this.raf.skipBytes(header.getRecordSizeInBytes() - numElementsInRecord);
}
return (array);
}
内容来源于网络,如有侵权,请联系作者删除!