/jEdit/tags/jedit-4-3-pre5/bsh/commands/load.bsh

# · Unknown · 22 lines · 17 code · 5 blank · 0 comment · 0 complexity · 3e0ebe34a8954f5b4d25e07502b7131b MD5 · raw file

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