7
코드가 session.connect
에서 중단되는 것 같습니다.java.io.IOException - IO 스트림의 마지막 읽기
com.jcraft.jsch.JSchException: Session.connect: java.io.IOException: End of IO Stream Read
스택 트레이스
com.jcraft.jsch.JSchException: Session.connect: java.io.IOException: End of IO Stream Read
at com.jcraft.jsch.Session.connect(Session.java:534)
at com.jcraft.jsch.Session.connect(Session.java:162)
at session.connect in uploadFile(ftpService.java:280)
코드 Jsch (예 : 0.1.52)과 OpenSSH를 최신 버전의 이전 버전과의 상호 운용성 문제가 발생했습니다
try {
JSch jsch = new JSch();
Session session = null;
session = jsch.getSession(ftpUserName, ftpServer, 22);
session.setClientVersion("StrictHostKeyChecking");
//session.setConfig("StrictHostKeyChecking", "no");
session.setPassword(ftpPassword);
session.connect();
Channel channel = session.openChannel("sftp");
channel.connect();
ChannelSftp sftpChannel = (ChannelSftp) channel;
//sftpChannel.get("remotefile.txt", "localfile.txt");
String path="C:\\srcFolder";
String remotePath="C:\\destFolder";
try {
sftpChannel.put(new FileInputStream(new File(path)), remotePath );
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
Logger.error(e);
e.printStackTrace();
}
final Vector files = sftpChannel.ls(".");
for (Object obj : files) {
System.out.println("f:"+obj);
}
sftpChannel.exit();
session.disconnect();
} catch (Exception e) {
e.printStackTrace();
}