/** * 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; }
/** * 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; }
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; }
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; }
@Override public String readUTF() throws IOException { try { return getRaf().readUTF(); } catch (IOException ioe) { handleException(); throw ioe; } }
String out = fh.readUTF(); System.err.println("Read: " + out);
/** * 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); }
/** * 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); }
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());
@NonNull @Override public String readUTF() throws IOException { return raf.readUTF(); } }
public String readFileDescription() throws IOException { raf.seek( FILE_DESCRIPTION ); String ret = raf.readUTF(); user_data = raf.getFilePointer(); return ret; }
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(); }
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)); } }
@Override public String readUTF() throws IOException { raf.seek(position); String utf8 = raf.readUTF(); buffer(raf.getFilePointer(), 0); return utf8; }
@Override public String readUTF() throws IOException { raf.seek(position); String utf8 = raf.readUTF(); buffer(raf.getFilePointer(), 0); return utf8; }
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); }
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());
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))); } }
private static String readFailureReason(final RandomAccessFile raf) throws IOException { BackupStatus status = readStatus(raf); if (status == BackupStatus.FAILED) { return raf.readUTF(); } return BackupStatus.UNKNOWN.name(); }
@Test(expected = FileReactiveAuditException.class) public void readUTF() throws IOException { ReactiveAudit.off.commit(); try (RandomAccessFile rw = newRandomAccessFile()) { TestTools.strict.commit(); rw.readUTF(); } }