try{ String fileName = "c:/myraffile.txt"; File file = new File(fileName); RandomAccessFile raf = new RandomAccessFile(file, "rw"); raf.readChar(); raf.seek(0); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
@Override public char readChar(int offset) { checkRead(offset, CHARACTER); try { seekToOffset(offset); return randomAccessFile.readChar(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public char readChar() throws IOException { try { return getRaf().readChar(); } catch (IOException ioe) { handleException(); throw ioe; } }
public char readChar() throws IOException { return delegate.readChar(); } public double readDouble() throws IOException { return delegate.readDouble(); }
File target = new File("/path/to/file"); RandomAccessFile file = new RandomAccessFile(target,"rwd"); file.seek(target.length()-1); // Set the pointer to the end of the file char c = file.readChar(); if(c == '|') // Change the pipe character to whatever your sentinel character is { file.setLength(target.length()-1); // Strip off the last _byte_, not the last character }
@Override public char readChar() throws IOException { return raf.readChar(); }
/** * Reads an unsigned char from the RandomAccessFile f. This method is a wrapper around {@link * java.io.RandomAccessFile#readChar() readChar()}, but assumes the output should be interpreted * as unsigned. */ @SuppressWarnings("signedness") public static @Unsigned char readUnsignedChar(RandomAccessFile f) throws IOException { return f.readChar(); }
/** * Reads an unsigned char from the RandomAccessFile f. This method is a wrapper around {@link * java.io.RandomAccessFile#readChar() readChar()}, but assumes the output should be interpreted * as unsigned. */ @SuppressWarnings("signedness") public static @Unsigned char readUnsignedChar(RandomAccessFile f) throws IOException { return f.readChar(); }
File f = new File("outputfile"); RandomAccessFile raf = new RandomAccessFile(f, "rw"); char ch = raf.readChar(); // establish the connection raf.seek(f.length()); // go to the end of the file raf.writeUTF("some string"); // write something raf.close(); // close it.
@Override public char readChar(long offset) { checkRead(offset, CHARACTER); try { seekToOffset(offset); return randomAccessFile.readChar(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public char readChar(long offset) { checkRead(offset, CHARACTER); try { seekToOffset(offset); return randomAccessFile.readChar(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public char readChar(long offset) { checkRead(offset, CHARACTER); try { seekToOffset(offset); return randomAccessFile.readChar(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public char readChar(int offset) { checkRead(offset, CHARACTER); try { seekToOffset(offset); return randomAccessFile.readChar(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public char readChar(long offset) { checkRead(offset, CHARACTER); try { seekToOffset(offset); return randomAccessFile.readChar(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public char readChar(int offset) { checkRead(offset, CHARACTER); try { seekToOffset(offset); return randomAccessFile.readChar(); } catch (IOException e) { throw new RuntimeException(e); } }
RandomAccessFile f = new RandomAccessFile("theRandomeAccessFile", "rw"); f.writeInt(1); f.writeDouble(2.34); f.writeUTF("SomeString"); f.writeChar('C'); f.seek(0); System.err.println(f.readInt()); System.err.println(f.readDouble()); System.err.println(f.readUTF()); System.err.println(f.readChar());
@Override public char readChar() throws IOException { try { return getRaf().readChar(); } catch (IOException ioe) { handleException(); throw ioe; } }
@Override public char readChar() throws IOException { try { return getRaf().readChar(); } catch (IOException ioe) { handleException(); throw ioe; } }
@Override public char readChar() throws IOException { try { return getRaf().readChar(); } catch (IOException ioe) { handleException(); throw ioe; } }
@Test(expected = FileReactiveAuditException.class) public void readChar() throws IOException { ReactiveAudit.off.commit(); try (RandomAccessFile rw = newRandomAccessFile()) { TestTools.strict.commit(); rw.readChar(); } }