PageRenderTime 16ms CodeModel.GetById 14ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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