Skip to content
Snippets Groups Projects
Commit ccd5d114 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

improve constructor

parent 5f6de754
No related branches found
No related tags found
No related merge requests found
...@@ -34,6 +34,10 @@ public class ScpClient implements Closeable { ...@@ -34,6 +34,10 @@ public class ScpClient implements Closeable {
private JSch jsch = new JSch(); private JSch jsch = new JSch();
private Session session; private Session session;
public ScpClient(String hostName, String username, byte[] privateKeyFile) throws JSchException {
init(hostName, username, new ByteIdentity(jsch, privateKeyFile));
}
public ScpClient(String hostName, String username, Identity privateKeyFile) throws JSchException { public ScpClient(String hostName, String username, Identity privateKeyFile) throws JSchException {
super(); super();
init(hostName, username, privateKeyFile); init(hostName, username, privateKeyFile);
...@@ -292,8 +296,9 @@ public class ScpClient implements Closeable { ...@@ -292,8 +296,9 @@ public class ScpClient implements Closeable {
@Override @Override
public void close() { public void close() {
if (session.isConnected()) { if ( session != null && session.isConnected()) {
session.disconnect(); session.disconnect();
session = null;
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment