void writeExternal( ObjectOutputStream out) throws IOException; void readExternal( ObjectInputStream in) throws IOException;The Kona Sheet class implements the java.io.Externalizable interface; consult the JDK 1.1 documentation for details on use of this interface. In the Kona Sheet, this interface allows for storage and retrieval of worksheet data. A prerequisite for use of these methods is that the needed stream reference be available. Note that the ability to open streams is affected by browser security policies. Example applet code is given below:
// save applet document data to a named file. return true for success. public boolean saveData( String filename, String appletname ) { Externalizable ext; File outFile; FileOutputStream fos; ObjectOutputStream oos; Applet theApplet = getAppletContext().getApplet( appletname ); // verify some params if ( null == filename || null == theApplet ) return false; // cast to Externalizable try { ext = (Externalizable)theApplet; } catch( ClassCastException e ) { return false; } // open the file and write the data try { outFile = new File( filename ); fos = new FileOutputStream( outFile ); oos = new ObjectOutputStream( fos ); ext.writeExternal( oos ); oos.close(); } catch( IOException e ) { return false; } // success return true; } // saveData
To execute properly in a browser environment, the above method must belong to an applet that is either loaded from a local workstation CLASSPATH, or has been configured as a "trusted" applet.