JSch
来源:互联网 发布:如何删除mac上的软件 编辑:程序博客网 时间:2024/05/23 12:49
package com.xyhj.lian.util;/** * Created by scott on 2017/6/19. */import java.io.File;import java.io.InputStream;import java.util.ArrayList;import java.util.List;import java.util.Properties;import java.util.Vector;import com.jcraft.jsch.Channel;import com.jcraft.jsch.ChannelSftp;import com.jcraft.jsch.ChannelSftp.LsEntry;import com.jcraft.jsch.JSch;import com.jcraft.jsch.Session; public class test1 { public static void main(String[] args) { //listFileNames("192.168.1.203", 22, "upload", "12lianupload", "/home/upload/"); } public static List<String> listFileNames(String host, int port, String username, final String password, String dir,InputStream in1 ) { List<String> list = new ArrayList<String>(); ChannelSftp sftp = null; Channel channel = null; Session sshSession = null; try { JSch jsch = new JSch(); sshSession = jsch.getSession(username, host, port); sshSession.setPassword(password); Properties sshConfig = new Properties(); sshConfig.put("StrictHostKeyChecking", "no"); sshSession.setConfig(sshConfig); sshSession.connect(); sftp = (ChannelSftp)sshSession.openChannel("sftp"); sftp.connect(); sftp.cd("/home/upload/"); sftp.put(in1,dir); } catch (Exception e) { e.printStackTrace(); } finally { closeChannel(sftp); closeChannel(channel); closeSession(sshSession); } return list; } public static void closeChannel(Channel channel) { if (channel != null) { if (channel.isConnected()) { channel.disconnect(); } } } public static void closeSession(Session session) { if (session != null) { if (session.isConnected()) { session.disconnect(); } } } }
阅读全文
0 0
- JSch
- JSch
- JSch
- JSch
- JSch
- JSch
- JSch
- JSch
- JSch
- JSch
- jsch example
- Jsch 深入浅出
- jsch初步
- jsch记录
- JSCH专题
- jsch教程
- Jsch学习
- Java中com.jcraft.jsch.JSch讲解
- 将两个升序链表合并成一个 升序链表
- HTTP 400错误
- K&R《C程序设计语言》p21:打印最长的输入行
- Mac 部署think PHP报错
- vuejs 无node单页应用方案二(babel-standalone or traceur,vue-router实现、组件按需懒加载)
- JSch
- git 在android studio中重新关联远程仓库地址的方法
- DOM与HTML DOM的区别与联系
- TensorFlow 读取CSV数据代码实现
- poj 1328 Radar Installation(贪心,线段重叠)
- SMTPC抄送邮件
- CSS属性margin负值与float效果浅谈
- Linux基础(六)
- (配置环境问题)svn插件和eclipse 整合不成功