daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest May 7th, 2016 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. String host = "166.62.85.112";
  2. int port = 22;
  3. String user = "username";
  4. String password = "password";
  5. String workingDirectory = "c:/";
  6.  
  7. Session session = null;
  8. Channel channel = null;
  9. ChannelSftp channelSftp = null;
  10.  
  11. try {
  12.     JSch jsch = new JSch();
  13.     session = jsch.getSession(user, host, port);
  14.     session.setPassword(password);
  15.     Properties config = new Properties();
  16.     config.put("StrictHostKeyChecking", "no");
  17.     session.setConfig(config);
  18.     session.connect();
  19.     channel = session.openChannel("sftp");
  20.     channel.connect();
  21.     channelSftp = (ChannelSftp) channel;
  22.     channelSftp.cd(workingDirectory);
  23.     File f = new File("D:/test.xlsx");
  24.     channelSftp.put(new FileInputStream(f), f.getName());
  25. } catch (Exception ex) {
  26.     ex.printStackTrace();
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top