1 package net.sf.jftp.net; 2 3 import java.util.Vector ; 4 5 import com.sshtools.j2ssh.configuration.SshConnectionProperties; 6 7 8 public class Sftp2Transfer implements Runnable 9 { 10 private String host; 11 private String localPath; 12 private String remotePath; 13 private String file; 14 private String user; 15 private String pass; 16 private Sftp2Connection con = null; 17 private String type; 18 public Thread runner; 19 private Vector listeners; 20 private String keyfile; 21 private String port; 22 23 public Sftp2Transfer(String localPath, String remotePath, 24 String file, String user, String pass, 25 Vector listeners, String type, String keyfile, String host, String port) 26 { 27 this.localPath = localPath; 28 this.remotePath = remotePath; 29 this.file = file; 30 this.user = user; 31 this.pass = pass; 32 this.type = type; 33 this.listeners = listeners; 34 this.keyfile = keyfile; 35 this.host = host; 36 this.port = port; 37 38 prepare(); 39 } 40 41 public void prepare() 42 { 43 runner = new Thread (this); 44 runner.setPriority(Thread.MIN_PRIORITY); 45 runner.start(); 46 } 47 48 public void run() 49 { 50 con = new Sftp2Connection(host, port, keyfile); 51 con.setConnectionListeners(listeners); 52 con.login(user, pass); 53 con.setLocalPath(localPath); 54 con.chdir(remotePath); 55 56 if(type.equals(Transfer.DOWNLOAD)) 57 { 58 con.download(file); 59 } 60 else if(type.equals(Transfer.UPLOAD)) 61 { 62 con.upload(file); 63 } 64 } 65 66 public Sftp2Connection getSftpConnection() 67 { 68 return con; 69 } 70 } 71 | Popular Tags |