public class SshUtils extends Object
Modifier and Type | Method and Description |
---|---|
protected static long |
byteStreamTransfer(InputStream in,
OutputStream out,
long size)
Reads from input stream and writes to output stream.
|
static int |
checkAck(InputStream in,
StringBuffer err)
Reads from the input stream; checks for status of ACK.
|
static void |
copyFrom(String remotePath,
String localPath,
SSHSession session)
Copy remote to local.
|
static void |
copyTo(String localPath,
String remotePath,
SSHSession session)
Copy local to remote.
|
static void |
deleteAll(String path,
boolean force,
SSHSession session)
Calls rm -rf.
|
static void |
deleteFile(String path,
boolean force,
SSHSession session)
Calls rm.
|
static void |
exec(SSHSession session,
String command)
Execs process without reading output stream, but throws exception if
error stream has been written to.
|
static void |
exec(SSHSession session,
String command,
OutputStream out,
OutputStream err)
Executes a single command using the given session; does not disconnect
session.
|
static void |
exec(SSHSession session,
String command,
StringBuffer stdout,
StringBuffer stderr)
Execs process, reading output stream into the string buffer; throws
exception if error stream has been written to.
|
static boolean |
exists(String path,
SSHSession session)
Checks for existence of path.
|
static boolean |
isDirectory(String path,
SSHSession session)
Checks for existence of directory.
|
static boolean |
isFile(String path,
SSHSession session)
Checks for existence of file.
|
static SSHSession |
maybeGetSession(URI contact,
String user,
String userHome) |
static void |
mkdirs(String path,
SSHSession session)
Makes directory and all its parents.
|
static void |
mv(String from,
String to,
SSHSession session)
For use on same file system instead of copy + delete.
|
static void |
removeDir(String path,
SSHSession session)
Calls rmdir.
|
static void |
touch(String path,
SSHSession session,
long timestamp)
Calls touch -m -t.
|
public static int checkAck(InputStream in, StringBuffer err) throws IOException
IOException
public static void copyFrom(String remotePath, String localPath, SSHSession session) throws Throwable
Throwable
public static void copyTo(String localPath, String remotePath, SSHSession session) throws Throwable
Throwable
public static void deleteAll(String path, boolean force, SSHSession session) throws IllegalArgumentException, Exception
IllegalArgumentException
Exception
public static void deleteFile(String path, boolean force, SSHSession session) throws IllegalArgumentException, Exception
IllegalArgumentException
Exception
public static void exec(SSHSession session, String command) throws IllegalArgumentException, Exception
IllegalArgumentException
Exception
public static void exec(SSHSession session, String command, OutputStream out, OutputStream err) throws IllegalArgumentException, Exception
IllegalArgumentException
Exception
public static void exec(SSHSession session, String command, StringBuffer stdout, StringBuffer stderr) throws IllegalArgumentException, Exception
IllegalArgumentException
Exception
public static boolean exists(String path, SSHSession session) throws NoSuchElementException, IllegalArgumentException, Exception
public static boolean isDirectory(String path, SSHSession session) throws NoSuchElementException, IllegalArgumentException, Exception
public static boolean isFile(String path, SSHSession session) throws NoSuchElementException, IllegalArgumentException, Exception
public static void mkdirs(String path, SSHSession session) throws IllegalArgumentException, Exception
IllegalArgumentException
Exception
public static void mv(String from, String to, SSHSession session) throws IllegalArgumentException, Exception
IllegalArgumentException
Exception
public static void removeDir(String path, SSHSession session) throws IllegalArgumentException, Exception
IllegalArgumentException
Exception
public static void touch(String path, SSHSession session, long timestamp) throws IllegalArgumentException, Exception
IllegalArgumentException
Exception
protected static long byteStreamTransfer(InputStream in, OutputStream out, long size) throws Throwable
in
- stream from which to read.out
- stream to which to write.size
- of source.Throwable
Copyright © 2016. All rights reserved.