本文整理了Java中java.io.RandomAccessFile.readUTF
方法的一些代码示例,展示了RandomAccessFile.readUTF
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomAccessFile.readUTF
方法的具体详情如下:
包路径:java.io.RandomAccessFile
类名称:RandomAccessFile
方法名:readUTF
[英]Reads a string that is encoded in DataInput from this file. The number of bytes that must be read for the complete string is determined by the first two bytes read from the file. Blocks until all required bytes have been read, the end of the file is reached or an exception is thrown.
[中]从该文件读取DataInput中编码的字符串。完整字符串必须读取的字节数由从文件中读取的前两个字节决定。块,直到读取完所有必需的字节、到达文件结尾或引发异常为止。
代码示例来源:origin: marytts/marytts
/**
* Method which loads the header from a RandomAccessFile.
*
* @param rafIn
* file to read from, must not be null.
* @throws IOException
* if no proc header can be read at the current position.
*/
private void loadProcHeader(RandomAccessFile rafIn) throws IOException {
assert rafIn != null : "null argument";
procHeader = rafIn.readUTF();
assert procHeader != null;
}
代码示例来源:origin: marytts/marytts
/**
* Method which loads the header from a RandomAccessFile.
*
* @param rafIn
* file to read from, must not be null.
* @throws IOException
* if no proc header can be read at the current position.
*/
private void loadProcHeader(RandomAccessFile rafIn) throws IOException {
assert rafIn != null : "null argument";
procHeader = rafIn.readUTF();
assert procHeader != null;
}
代码示例来源: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: 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: apache/activemq
@Override
public String readUTF() throws IOException {
try {
return getRaf().readUTF();
} catch (IOException ioe) {
handleException();
throw ioe;
}
}
代码示例来源:origin: stackoverflow.com
String out = fh.readUTF();
System.err.println("Read: " + out);
代码示例来源:origin: ahmetaa/zemberek-nlp
/**
* Generates a vocabulary from a binary RandomAccessFile. first integer read from the file pointer
* defines the vocabulary size. Rest is read in UTF. Constructor does not close the
* RandomAccessFile
*
* @param raf binary vocabulary RandomAccessFile
*/
private LmVocabulary(RandomAccessFile raf) throws IOException {
int vocabLength = raf.readInt();
List<String> vocabulary = new ArrayList<>(vocabLength);
for (int i = 0; i < vocabLength; i++) {
vocabulary.add(raf.readUTF());
}
generateMap(vocabulary);
}
代码示例来源:origin: geotools/geotools
/**
* Reads the next feature form the file
*
* @return
* @throws IOException
*/
public SimpleFeature read() throws IOException {
// read the fid, check for file end
String fid = raf.readUTF();
// read the other attributes, build the feature
for (AttributeDescriptor ad : schema.getAttributeDescriptors()) {
Object att = readAttribute(ad);
builder.add(att);
}
// return the feature
return builder.buildFeature(fid);
}
代码示例来源:origin: geotools/geotools
return raf.readDouble();
} else if (binding == String.class) {
return raf.readUTF();
} else if (binding == java.sql.Date.class) {
return new java.sql.Date(raf.readLong());
代码示例来源:origin: topjohnwu/libsu
@NonNull
@Override
public String readUTF() throws IOException {
return raf.readUTF();
}
}
代码示例来源:origin: org.scijava/j3dutils
public String readFileDescription() throws IOException {
raf.seek( FILE_DESCRIPTION );
String ret = raf.readUTF();
user_data = raf.getFilePointer();
return ret;
}
代码示例来源:origin: stackoverflow.com
try (RandomAccessFile raf = new RandomAccessFile("jedis.bin", "r")) {
raf.seek(16);
String val = raf.readUTF();
System.out.println(val); //prints Yoda
} catch (IOException e) {
e.printStackTrace();
}
代码示例来源:origin: quickfix-j/quickfixj
private void initializeSequenceNumbers() throws IOException {
senderSequenceNumberFile.seek(0);
if (senderSequenceNumberFile.length() > 0) {
final String s = senderSequenceNumberFile.readUTF();
cache.setNextSenderMsgSeqNum(Integer.parseInt(s));
}
targetSequenceNumberFile.seek(0);
if (targetSequenceNumberFile.length() > 0) {
final String s = targetSequenceNumberFile.readUTF();
cache.setNextTargetMsgSeqNum(Integer.parseInt(s));
}
}
代码示例来源:origin: org.openmicroscopy/ome-common
@Override
public String readUTF() throws IOException {
raf.seek(position);
String utf8 = raf.readUTF();
buffer(raf.getFilePointer(), 0);
return utf8;
}
代码示例来源:origin: ome/formats-common
@Override
public String readUTF() throws IOException {
raf.seek(position);
String utf8 = raf.readUTF();
buffer(raf.getFilePointer(), 0);
return utf8;
}
代码示例来源:origin: openimaj/openimaj
private String getImageId(int i) throws IOException {
final long seekId = indexes[i];
final long offset = offsets[i];
imageData.seek(offset);
final long id = imageData.readLong();
final int farm = imageData.readInt();
final int server = imageData.readInt();
final String secret = imageData.readUTF();
return String.format(imageFormat, farm, server, id, secret);
}
代码示例来源:origin: stackoverflow.com
RandomAccessFile raf = new RandomAccessFile(path,permissions); //permissions are r,w,rw. The usual ones.
raf.seek(0); //this will set the pointer to first position.
raf.writeUTF(what ever you want to write to file);
//to read the file use readUTF()
raf.seek(0); //you can read from a part of file using this seek method.
System.out.println(raf.readUTF());
代码示例来源:origin: quickfix-j/quickfixj
private void initializeSequenceNumbers() throws IOException {
sequenceNumberFile.seek(0);
if (sequenceNumberFile.length() > 0) {
final String s = sequenceNumberFile.readUTF();
final int offset = s.indexOf(':');
if (offset < 0) {
throw new IOException("Invalid sequenceNumbderFile '" + seqNumFileName
+ "' character ':' is missing");
}
cache.setNextSenderMsgSeqNum(Integer.parseInt(s.substring(0, offset)));
cache.setNextTargetMsgSeqNum(Integer.parseInt(s.substring(offset + 1)));
}
}
代码示例来源:origin: org.terracotta/terracotta-ee
private static String readFailureReason(final RandomAccessFile raf) throws IOException {
BackupStatus status = readStatus(raf);
if (status == BackupStatus.FAILED) { return raf.readUTF(); }
return BackupStatus.UNKNOWN.name();
}
代码示例来源:origin: octo-online/reactive-audit
@Test(expected = FileReactiveAuditException.class)
public void readUTF()
throws IOException
{
ReactiveAudit.off.commit();
try (RandomAccessFile rw = newRandomAccessFile())
{
TestTools.strict.commit();
rw.readUTF();
}
}
内容来源于网络,如有侵权,请联系作者删除!