FileChannel: position(long newPosition)
abstract FileChannel position(long newPosition)
- Sets this channel's file position.
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
public class Main {
private static final int BSIZE = 1024;
public static void main(String[] args) throws Exception {
FileChannel fc = new RandomAccessFile("data.txt", "rw").getChannel();
fc.position(fc.size());
fc.write(ByteBuffer.wrap("Some more".getBytes()));
fc.close();
}
}
Home
Java Book
File Stream
Java Book
File Stream
FileChannel:
- FileChannel
- FileChannel.MapMode.READ_WRITE
- FileChannel: close()
- FileChannel: lock(long position, long size, boolean shared)
- FileChannel: map(MapMode mode, long position, long size)
- FileChannel: position()
- FileChannel: position(long newPosition)
- FileChannel: read(ByteBuffer dst)
- FileChannel: size()
- FileChannel: transferFrom(ReadableByteChannel src, long position, long count)
- FileChannel: transferTo(long position, long count, WritableByteChannel target)
- FileChannel: tryLock()
- FileChannel: write(MappedByteBuffer buffer)