本文整理了Java中java.io.RandomAccessFile.readByte
方法的一些代码示例,展示了RandomAccessFile.readByte
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomAccessFile.readByte
方法的具体详情如下:
包路径:java.io.RandomAccessFile
类名称:RandomAccessFile
方法名:readByte
[英]Reads an 8-bit byte from the current position in this file. Blocks until one byte has been read, the end of the file is reached or an exception is thrown.
[中]从文件中的当前位置读取8位字节。块,直到读取一个字节、到达文件结尾或引发异常为止。
代码示例来源:origin: stackoverflow.com
RandomAccessFile in = new RandomAccessFile("filename", "r");
int version = in.readInt();
byte type = in.readByte();
int beginOfData = in.readInt();
byte[] tempId;
in.read(tempId, 0, 16);
String id = new String(tempId);
代码示例来源:origin: CarGuo/GSYVideoPlayer
static void modify(File file) throws IOException {
long size = file.length();
if (size == 0) {
recreateZeroSizeFile(file);
return;
}
RandomAccessFile accessFile = new RandomAccessFile(file, "rwd");
accessFile.seek(size - 1);
byte lastByte = accessFile.readByte();
accessFile.seek(size - 1);
accessFile.write(lastByte);
accessFile.close();
}
代码示例来源:origin: stackoverflow.com
RandomAccessFile f = new RandomAccessFile(fileName, "rw");
long length = f.length() - 1;
do {
length -= 1;
f.seek(length);
byte b = f.readByte();
} while(b != 10);
f.setLength(length+1);
f.close();
代码示例来源:origin: apache/flume
public void markRecordAsNoop(long offset) throws IOException {
// First ensure that the offset actually is an OP_RECORD. There is a
// small possibility that it still is OP_RECORD,
// but is not actually the beginning of a record. Is there anything we
// can do about it?
fileHandle.seek(offset);
byte byteRead = fileHandle.readByte();
Preconditions.checkState(byteRead == OP_RECORD || byteRead == OP_NOOP,
"Expected to read a record but the byte read indicates EOF");
fileHandle.seek(offset);
LOG.info("Marking event as " + OP_NOOP + " at " + offset + " for file " +
file.toString());
fileHandle.writeByte(OP_NOOP);
}
代码示例来源:origin: stackoverflow.com
int readByte = fileHandler.readByte();
代码示例来源:origin: stackoverflow.com
int readByte = fileHandler.readByte();
代码示例来源:origin: stanfordnlp/CoreNLP
byte c = raf.readByte();
if(c == '\n'){
代码示例来源:origin: atomix/atomix
@Override
public int readByte(int offset) {
checkRead(offset, BYTE);
try {
seekToOffset(offset);
return randomAccessFile.readByte();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: smuyyh/BookReader
for (long i = raf.length() - 1; i > b.length + skip - 1; i--) {
raf.seek(i - b.length);
byte temp = raf.readByte();
raf.seek(i);
raf.writeByte(temp);
代码示例来源:origin: sleekbyte/tailor
/**
* Checks whether a file is terminated with exactly one trailing newline.
*
* @param inputFile the file to check for a trailing newline
* @return true if file is terminated with exactly one newline
* @throws IOException if the file cannot be read
*/
public static boolean singleNewlineTerminated(File inputFile) throws IOException {
RandomAccessFile randomAccessFile = new RandomAccessFile(inputFile, READ_ONLY_MODE);
// Zero terminating newlines
if (inputFile.length() < 1) {
return true;
}
randomAccessFile.seek(inputFile.length() - 1);
if (Byte.compare(randomAccessFile.readByte(), NEWLINE_DELIMITER) != 0) {
return false;
}
// File contains a single newline character and nothing else
if (inputFile.length() < 2) {
return true;
}
// More than one terminating newline
randomAccessFile.seek(inputFile.length() - 2);
return (Byte.compare(randomAccessFile.readByte(), NEWLINE_DELIMITER) != 0);
}
代码示例来源:origin: jenkinsci/jenkins
byte readByte = fileHandler.readByte();
代码示例来源:origin: jenkinsci/jenkins
argp = adjustL(psinfo.readLong());
envp = adjustL(psinfo.readLong());
b64 = (psinfo.readByte() == PR_MODEL_LP64);
} else {
psinfo.seek(188); // offset of pr_argc
argp = to64(adjust(psinfo.readInt()));
envp = to64(adjust(psinfo.readInt()));
b64 = (psinfo.readByte() == PR_MODEL_LP64);
代码示例来源:origin: apache/activemq
@Override
public byte readByte() throws IOException {
try {
return getRaf().readByte();
} catch (IOException ioe) {
handleException();
throw ioe;
}
}
代码示例来源:origin: apache/flume
Preconditions.checkState(offset >= 0);
while (offset < fileHandle.length()) {
byte operation = fileHandle.readByte();
if (operation == OP_RECORD) {
break;
代码示例来源:origin: stackoverflow.com
int readByte = in.readByte();
int readByte = in.readByte();
return readByte;
代码示例来源:origin: GlowstoneMC/Glowstone
byte version = file.readByte();
if (version == VERSION_GZIP) {
byte[] data = new byte[length - 1];
代码示例来源:origin: jenkinsci/jenkins
byte pr_dmodel = pstatus.readByte();
代码示例来源:origin: apache/flume
try {
fileHandle.seek(offset);
byte operation = fileHandle.readByte();
if (operation == OP_NOOP) {
throw new NoopRecordException("No op record found. Corrupt record " +
代码示例来源:origin: i2p/i2p.i2p
public byte readByte() throws IOException { return delegate.readByte(); }
public char readChar() throws IOException { return delegate.readChar(); }
代码示例来源:origin: net.java.dev.jna/jna
byte sizeIndicator = raf.readByte();
byte endianessIndicator = raf.readByte();
_64Bit = sizeIndicator == EI_CLASS_64BIT;
bigEndian = endianessIndicator == EI_DATA_BIG_ENDIAN;
内容来源于网络,如有侵权,请联系作者删除!