home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
jbuilder
/
jsamples.z
/
Serial1.java
< prev
next >
Wrap
Text File
|
1997-07-30
|
1KB
|
55 lines
// Copyright(c) 1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
import java.io.*;
import java.util.*;
public class Serial1
{
static public void write()
{
try
{
// create a map of acronyms
HashMap map = new HashMap();
map.add( "FAQ", "Frequently Asked Questions" );
map.add( "OMG", "Object Management Group" );
map.add( "ORB", "Object Request Broker" );
// save map to a file
ObjectOutput s = new ObjectOutputStream( new FileOutputStream( "Serial1.bin" ) );
s.writeObject( map );
}
catch ( IOException e )
{
System.out.println( "caught: " + e );
}
}
static public void read()
{
try
{
// read map from file
ObjectInputStream s = new ObjectInputStream( new FileInputStream( "Serial1.bin" ) );
HashMap map = (HashMap)s.readObject();
System.out.println( "ORB means " + map.get( "ORB" ) );
System.out.println( "FAQ means " + map.get( "FAQ" ) );
}
catch ( IOException e1 )
{
System.out.println( "caught: " + e1 );
}
catch ( ClassNotFoundException e2 )
{
System.out.println( "caught: " + e2 );
}
}
public static void main( String args[] )
{
write();
read();
}
}