PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

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

#
Unknown | 21 lines | 16 code | 5 blank | 0 comment | 0 complexity | 7e8ef0b21d06afc6aa50a01431d7bc36 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  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. file = pathToFile( filename );
  7. Object obj;
  8. FileInputStream in = new FileInputStream( file );
  9. ObjectInputStream oin = new ObjectInputStream(in);
  10. obj = oin.readObject();
  11. oin.close();
  12. // bind bsh objects into the caller's namespace
  13. if ( obj instanceof bsh.This )
  14. bind( obj, this.caller.namespace );
  15. return obj;
  16. }