O'Reilly logo

Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython by Richard Hightower

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The RandomAccessFile Class

RandomAccessFile both reads and writes to binary output streams. It's most similar to the Python file object and has the following methods:

  • __init__(strName, strMode)— opens the file in the specified mode

  • __init__(File, strMode)— same as above, but passes a Java file object

  • getFD()— gets the file descriptor

  • getFilePointer()— similar to the tell() method for the Python file object

  • length()— gets the length of the file

  • seek()— similar to the seek() method for the Python file object

  • read(byte_sequence)— similar to the read() method in InputStream

  • read(byte_sequence, off, len)— similar to the read() method in InputStream

The following abstract methods are from DataInput:

  • readBoolean()

  • readByte()

  • readFloat()

  • readChar()

  • readDouble() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required