import jcifs.smb.*;



public class TestCopy {
	
	
    public static void main( String[] args ) throws Exception {

    	String file1=("smb://123.123.123.123/Xtemp/test1.txt");
    	String file2=("smb://123.123.123.123/Xtemp/test2.txt");
    	
    	jcifs.Config.setProperty( "jcifs.smb.client.username", "username");
    	jcifs.Config.setProperty( "jcifs.smb.client.password", "password");
    	jcifs.Config.setProperty( "jcifs.smb.client.domain", "mydomain.pri");

    	try 	{
            SmbFile remote = new SmbFile( file1 );
                if( remote.exists() ) {
                    SmbFile local = new SmbFile( file2 );
                    remote.copyTo( local );
                }
            } catch( Exception e ) {
                System.err.println( file1 + " -> " + file2 );
                e.printStackTrace();
            }
        }
}
  • code/java/jcif-copy.txt
  • Last modified: 2018/05/19 20:43
  • by gerardorourke