home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Shareware / Comunicatii / advwebrank / awr.msi / disk1.cab / bsh_1.2b6.jar / bsh / commands / load.bsh < prev    next >
Encoding:
Text File  |  2002-05-26  |  474 b   |  22 lines

  1. /**
  2.     Load a serialized Java object from filename.  Returns the object.
  3. */
  4.  
  5. bsh.help.load = "usage: load(filename)";
  6.  
  7. Object load( String filename ) {
  8.     file = pathToFile( filename );
  9.  
  10.     Object obj;
  11.     FileInputStream in = new FileInputStream( file );
  12.     ObjectInputStream oin = new ObjectInputStream(in);
  13.     obj = oin.readObject();
  14.     oin.close();
  15.  
  16.     // bind bsh objects into the caller's namespace
  17.     if ( obj instanceof bsh.This )
  18.         bind( obj, this.caller.namespace );
  19.  
  20.     return obj;
  21. }
  22.