Add write support for RandomAccessFile

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2013-10-17 14:46:00 -05:00
parent 905ddfe613
commit 2c0a1c726d
2 changed files with 54 additions and 0 deletions

View File

@ -131,6 +131,14 @@ public class RandomAccessFile {
private static native int readBytes(long peer, long position, byte[] buffer,
int offset, int length);
public void write(int b) throws IOException {
int count = writeBytes(peer, position, new byte[] { (byte)b }, 0, 1);
if (count > 0) position += count;
}
private static native int writeBytes(long peer, long position, byte[] buffer,
int offset, int length);
public void close() throws IOException {
if (peer != 0) {
close(peer);