PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre4/bsh/commands/cp.bsh

#
Unknown | 20 lines | 16 code | 4 blank | 0 comment | 0 complexity | 58e1a98cf2974bf26e9bc2829147e4ac 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. Copy a file (like Unix cp).
  3. */
  4. bsh.help.cp = "usage: cp( fromFile, toFile )";
  5. cp( String fromFile, String toFile )
  6. {
  7. this.from = pathToFile( fromFile );
  8. this.to = pathToFile( toFile );
  9. this.in = new BufferedInputStream( new FileInputStream( from ) );
  10. this.out = new BufferedOutputStream( new FileOutputStream( to ) );
  11. byte [] buff = new byte [ 32*1024 ];
  12. while ( (len = in.read( buff )) > 0 )
  13. out.write( buff, 0, len );
  14. in.close();
  15. out.close();
  16. }