/usr/share/doc/libjcifs-java/examples/VerifyIO.java is in libjcifs-java-doc 1.3.19-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | import java.net.MalformedURLException;
import jcifs.smb.*;
import java.io.*;
public class VerifyIO {
static File get( SmbFile f0 ) throws Exception {
int i;
File f1;
byte[] buf = new byte[8192];
f1 = new File( f0.getName() );
FileOutputStream out = new FileOutputStream( f1 );
SmbFileInputStream in = new SmbFileInputStream( f0 );
while(( i = in.read( buf )) > 0 ) {
out.write( buf, 0, i );
System.err.print( '.' );
}
in.close();
out.close();
return f1;
}
static void put( SmbFile f2 ) throws Exception {
int i;
byte[] buf = new byte[8192];
FileInputStream in = new FileInputStream( f2.getName() );
SmbFileOutputStream out = new SmbFileOutputStream( f2 );
while(( i = in.read( buf )) > 0 ) {
out.write( buf, 0, i );
System.err.print( '-' );
}
in.close();
out.close();
}
public static void main(String[] argv) throws Exception {
BufferedReader in;
String name;
if( argv.length < 2 ) {
System.err.println( "Must provide file of SMB URLs and destination directory" );
System.exit( 1 );
}
in = new BufferedReader( new FileReader( argv[0] ));
while(( name = in.readLine() ) != null ) {
SmbFile f0, f2;
File f1;
System.err.print( name + ": " );
f0 = new SmbFile( name );
f1 = get( f0 );
if( f0.length() != f1.length() ) {
throw new RuntimeException( "File lengths do not match: f0=" + f0.length() + ",f1=" + f1.length() );
}
f2 = new SmbFile( argv[1] + "/" + f0.getName() );
put( f2 );
if( f1.length() != f2.length() ) {
throw new RuntimeException( "File lengths do not match: f1=" + f1.length() + ",f2=" + f2.length() );
}
f1.delete();
System.err.println( " ok" );
}
}
}
|