本文整理了Java中java.io.RandomAccessFile.readLong
方法的一些代码示例,展示了RandomAccessFile.readLong
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomAccessFile.readLong
方法的具体详情如下:
包路径:java.io.RandomAccessFile
类名称:RandomAccessFile
方法名:readLong
[英]Reads a big-endian 64-bit long from the current position in this file. Blocks until eight bytes have been read, the end of the file is reached or an exception is thrown.
[中]从文件中的当前位置读取64位长的大端字节。块,直到读取了八个字节,到达文件末尾或引发异常。
代码示例来源:origin: scouter-project/scouter
private void load() throws IOException {
raf.seek(0);
counts = raf.readLong();
}
代码示例来源:origin: robovm/robovm
/**
* Reads a big-endian 64-bit double from the current position in this file. Blocks
* until eight bytes have been read, the end of the file is reached or an
* exception is thrown.
*
* @return the next double value from this file.
* @throws EOFException
* if the end of this file is detected.
* @throws IOException
* if this file is closed or another I/O error occurs.
* @see #writeDouble(double)
*/
public final double readDouble() throws IOException {
return Double.longBitsToDouble(readLong());
}
代码示例来源:origin: marytts/marytts
/**
* Constructor which reads a datagram from a random access file.
*
* @param raf
* the random access file to read the datagram from.
*
* @throws IOException
* if there is a problem initialising the datagram from the file
*/
public Datagram(RandomAccessFile raf) throws IOException {
duration = raf.readLong();
if (duration < 0) {
throw new IOException("Can't create a datagram with a negative duration [" + duration + "].");
}
int len = raf.readInt();
if (len < 0) {
throw new IOException("Can't create a datagram with a negative data size [" + len + "].");
}
data = new byte[len];
raf.readFully(data);
}
代码示例来源:origin: marytts/marytts
/**
* Constructor which reads a datagram from a random access file.
*
* @param raf
* the random access file to read the datagram from.
*
* @throws IOException
* if there is a problem initialising the datagram from the file
*/
public Datagram(RandomAccessFile raf) throws IOException {
duration = raf.readLong();
if (duration < 0) {
throw new IOException("Can't create a datagram with a negative duration [" + duration + "].");
}
int len = raf.readInt();
if (len < 0) {
throw new IOException("Can't create a datagram with a negative data size [" + len + "].");
}
data = new byte[len];
raf.readFully(data);
}
代码示例来源:origin: graphhopper/graphhopper
protected long readHeader(RandomAccessFile raFile) throws IOException {
raFile.seek(0);
if (raFile.length() == 0)
return -1;
String versionHint = raFile.readUTF();
if (!"GH".equals(versionHint))
throw new IllegalArgumentException("Not a GraphHopper file! Expected 'GH' as file marker but was " + versionHint);
long bytes = raFile.readLong();
setSegmentSize(raFile.readInt());
for (int i = 0; i < header.length; i++) {
header[i] = raFile.readInt();
}
return bytes;
}
代码示例来源:origin: lealone/Lealone
private synchronized int readLastChunkId() throws IOException {
if (chunkMetaData.length() <= 0)
return 0;
int lastChunkId = chunkMetaData.readInt();
int removedPagesCount = chunkMetaData.readInt();
for (int i = 0; i < removedPagesCount; i++)
removedPages.add(chunkMetaData.readLong());
int hashCodeToHostIdMapSize = chunkMetaData.readInt();
for (int i = 0; i < hashCodeToHostIdMapSize; i++)
addHostIds(chunkMetaData.readUTF());
return lastChunkId;
}
代码示例来源:origin: jenkinsci/jenkins
if (adjust((int)pstatus.readLong()) != pid)
throw new IOException("pstatus PID mismatch"); // sanity check
ppid = adjust((int)pstatus.readLong()); // AIX pids are stored as a 64 bit integer,
if (adjust((int)psinfo.readLong()) != pid)
throw new IOException("psinfo PID mismatch"); // sanity check
if (adjust((int)psinfo.readLong()) != ppid)
throw new IOException("psinfo PPID mismatch"); // sanity check
pr_argp = adjustL(psinfo.readLong());
pr_envp = adjustL(psinfo.readLong());
} finally {
psinfo.close();
代码示例来源:origin: atomix/atomix
@Override
public long readLong(int offset) {
checkRead(offset, LONG);
try {
seekToOffset(offset);
return randomAccessFile.readLong();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: lealone/Lealone
private synchronized TreeSet<Long> readRemovedPages() {
try {
TreeSet<Long> removedPages = new TreeSet<>();
if (chunkMetaData.length() > 8) {
chunkMetaData.seek(4);
int removedPagesCount = chunkMetaData.readInt();
for (int i = 0; i < removedPagesCount; i++)
removedPages.add(chunkMetaData.readLong());
}
return removedPages;
} catch (IOException e) {
throw panic(DataUtils.newIllegalStateException(DataUtils.ERROR_READING_FAILED, "Failed to readRemovedPages",
e));
}
}
代码示例来源:origin: marytts/marytts
/**
* Constructor which pops a datagram from a random access file.
*
* @param raf
* the random access file to pop the datagram from.
* @param noiseModel
* the noise model
* @throws IOException
* IOException
* @throws EOFException
* EOFException
*/
public HnmDatagram(RandomAccessFile raf, int noiseModel) throws IOException, EOFException {
super(raf.readLong()); // duration
int len = raf.readInt();
if (len < 0) {
throw new IOException("Can't create a datagram with a negative data size [" + len + "].");
}
if (len < 4 * 3) {
throw new IOException("Hnm with waveform noise datagram too short (len=" + len
+ "): cannot be shorter than the space needed for first three Hnm parameters (4*3)");
}
// For speed concerns, read into a byte[] first:
byte[] buf = new byte[len];
raf.readFully(buf);
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buf));
frame = new HntmSpeechFrame(dis, noiseModel);
}
代码示例来源:origin: apache/flume
SequentialReader(File file) throws EOFException, IOException {
super(file, null);
RandomAccessFile fileHandle = getFileHandle();
int version = fileHandle.readInt();
if (version != getVersion()) {
throw new IOException("Version is " + Integer.toHexString(version) +
" expected " + Integer.toHexString(getVersion())
+ " file: " + file.getCanonicalPath());
}
setLogFileID(fileHandle.readInt());
setLastCheckpointPosition(fileHandle.readLong());
setLastCheckpointWriteOrderID(fileHandle.readLong());
}
代码示例来源:origin: jenkinsci/jenkins
psinfo.seek(236); // offset of pr_argc
argc = adjust(psinfo.readInt());
argp = adjustL(psinfo.readLong());
envp = adjustL(psinfo.readLong());
b64 = (psinfo.readByte() == PR_MODEL_LP64);
} else {
代码示例来源:origin: marytts/marytts
/**
* Constructor which pops a datagram from a random access file.
*
* @param raf
* the random access file to pop the datagram from.
* @param noiseModel
* the noise model
* @throws IOException
* IOException
* @throws EOFException
* EOFException
*/
public HnmDatagram(RandomAccessFile raf, int noiseModel) throws IOException, EOFException {
super(raf.readLong()); // duration
int len = raf.readInt();
if (len < 0) {
throw new IOException("Can't create a datagram with a negative data size [" + len + "].");
}
if (len < 4 * 3) {
throw new IOException("Hnm with waveform noise datagram too short (len=" + len
+ "): cannot be shorter than the space needed for first three Hnm parameters (4*3)");
}
// For speed concerns, read into a byte[] first:
byte[] buf = new byte[len];
raf.readFully(buf);
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buf));
frame = new HntmSpeechFrame(dis, noiseModel);
}
代码示例来源:origin: apache/activemq
@Override
public long readLong() throws IOException {
try {
return getRaf().readLong();
} catch (IOException ioe) {
handleException();
throw ioe;
}
}
代码示例来源:origin: oracle/opengrok
public FNode(RandomAccessFile f) throws Throwable {
offset = f.getFilePointer();
hash = f.readLong();
childOffset = f.readUnsignedShort();
numChildren = f.readUnsignedShort();
tagOffset = f.readUnsignedShort();
}
代码示例来源:origin: oracle/opengrok
public FNode() throws IOException {
offset = f.getFilePointer();
try {
hash = f.readLong();
childOffset = f.readUnsignedShort();
numChildren = f.readUnsignedShort();
tagOffset = f.readUnsignedShort();
} catch (EOFException e) {
numChildren = 0;
tagOffset = 0;
}
}
代码示例来源:origin: aragozin/jvm-tools
LongBuffer revertBuffer() throws IOException {
LongBuffer reverted = new LongBuffer(buffer.length);
if (bufferSize < buffer.length) {
for (int i=0;i<bufferSize;i++) {
reverted.writeLong(buffer[bufferSize - 1 - i]);
}
} else {
writeStream.flush();
RandomAccessFile raf = new RandomAccessFile(backingFile,"r");
long offset = raf.length();
while(offset > 0) {
offset-=8;
raf.seek(offset);
reverted.writeLong(raf.readLong());
}
}
reverted.startReading();
return reverted;
}
代码示例来源:origin: oracle/opengrok
private FNode binarySearch(long start, int len, long hash) throws IOException {
int b = 0;
int e = len;
while (b <= e) {
int m = (b + e) / 2;
f.seek(start + m * EftarFile.RECORD_LENGTH);
long mhash = f.readLong();
if (hash > mhash) {
b = m + 1;
} else if (hash < mhash) {
e = m - 1;
} else {
return new FNode(mhash, f.getFilePointer() - 8l, f.readUnsignedShort(), f.readUnsignedShort(), f.readUnsignedShort());
}
}
return null;
}
代码示例来源:origin: oracle/opengrok
private FNode sbinSearch(long start, int len, long hash, RandomAccessFile f) throws Throwable {
int b = 0;
int e = len;
while (b <= e) {
int m = (b + e) / 2;
f.seek(start + m * RECORD_LENGTH);
long mhash = f.readLong();
if (hash > mhash) {
b = m + 1;
} else if (hash < mhash) {
e = m - 1;
} else {
return new FNode(mhash, f.getFilePointer() - 8l, f.readUnsignedShort(), f.readUnsignedShort(), f.readUnsignedShort());
}
}
return null;
}
}
代码示例来源:origin: apache/flume
protected MetaDataWriter(File file, int logFileID) throws IOException {
super(file, logFileID);
boolean error = true;
try {
RandomAccessFile writeFileHandle = getFileHandle();
int version = writeFileHandle.readInt();
if (version != getVersion()) {
throw new IOException("The version of log file: "
+ file.getCanonicalPath() + " is different from expected "
+ " version: expected = " + getVersion() + ", found = " + version);
}
int fid = writeFileHandle.readInt();
if (fid != logFileID) {
throw new IOException("The file id of log file: "
+ file.getCanonicalPath() + " is different from expected "
+ " id: expected = " + logFileID + ", found = " + fid);
}
setLastCheckpointOffset(writeFileHandle.readLong());
setLastCheckpointWriteOrderID(writeFileHandle.readLong());
LOGGER.info("File: " + file.getCanonicalPath() + " was last checkpointed "
+ "at position: " + getLastCheckpointOffset()
+ ", logWriteOrderID: " + getLastCheckpointWriteOrderID());
error = false;
} finally {
if (error) {
close();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!