1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class Copy {
public static void main(String[] args) throws Exception {
if ( args.length == 0 ) {
System.out.println( "Usage: java Copy srcFile destFile" );
System.exit( 0 );
}
File sourceFile = new File( args[0] );
FileInputStream fis = new FileInputStream( sourceFile );
FileOutputStream fos = new FileOutputStream( args[1] );
byte [] buffer = new byte[ 1024 * 1024 ]; // 1 mega bytes
long length = sourceFile.length();
while( length > 0 ) {
int readedBytesCount = fis.read( buffer );
fos.write( buffer, 0, readedBytesCount );
length -= readedBytesCount;
}
fis.close();
fos.close();
}
}
|
Améliorations / Corrections
Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Emplacement :
Description des améliorations :