FileDocCategorySizeDatePackage
FilePointer.javaAPI DocExample985Tue Feb 19 18:16:32 GMT 2002com.ronsoft.books.nio.channels

FilePointer

public class FilePointer extends Object
Test file pointer manipulation between FileChannel and RandomAccessFile objects. Created Feb 2002
author
Ron Hitchens (ron@ronsoft.com)
version
$Id: FilePointer.java,v 1.1 2002/02/20 03:16:33 ron Exp $

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)

		RandomAccessFile randomAccessFile = new RandomAccessFile (argv [0], "r");

		randomAccessFile.seek (1000);

		FileChannel fileChannel = randomAccessFile.getChannel();

		// This will print "1000"
		System.out.println ("file pos: " + fileChannel.position());

		randomAccessFile.seek (500);

		// This will print "500"
		System.out.println ("file pos: " + fileChannel.position());

		fileChannel.position (200);

		// This will print "200"
		System.out.println ("file pos: " + randomAccessFile.getFilePointer());