FileDocCategorySizeDatePackage
SerializableRandomAccessFile.javaAPI DocExample1053Sun Mar 28 19:08:06 BST 1999None

SerializableRandomAccessFile

public class SerializableRandomAccessFile extends RandomAccessFile implements Serializable

Fields Summary
Constructors Summary
public SerializableRandomAccessFile(String name, String mode)

    super(name, mode);
  
public SerializableRandomAccessFile(File file, String mode)

    super(file, mode);
  
Methods Summary
public static voidmain(java.lang.String[] args)


    try {
      SerializableRandomAccessFile sraf = new 
       SerializableRandomAccessFile(args[0], args[1]);
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(bos);
      oos.writeObject(sraf);
      oos.close();
      System.out.println("Wrote object!");

      ByteArrayInputStream bis = new 
       ByteArrayInputStream(bos.toByteArray());
      ObjectInputStream ois = new ObjectInputStream(bis);
      Object o = ois.readObject();
      System.out.println("Read object!");
    }
    catch (Exception e) {
      System.err.println(e);
    }