/jEdit/tags/jedit-4-3-pre5/bsh/commands/cp.bsh
# · Unknown · 20 lines · 16 code · 4 blank · 0 comment · 0 complexity · 58e1a98cf2974bf26e9bc2829147e4ac MD5 · raw file
- /**
- Copy a file (like Unix cp).
- */
- bsh.help.cp = "usage: cp( fromFile, toFile )";
- cp( String fromFile, String toFile )
- {
- this.from = pathToFile( fromFile );
- this.to = pathToFile( toFile );
- this.in = new BufferedInputStream( new FileInputStream( from ) );
- this.out = new BufferedOutputStream( new FileOutputStream( to ) );
- byte [] buff = new byte [ 32*1024 ];
- while ( (len = in.read( buff )) > 0 )
- out.write( buff, 0, len );
- in.close();
- out.close();
- }