public class Util
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
S_IFMT
Permissions flag: Format mask constant can be used to mask off a file
type from the mode.
|
static int |
S_ISGID
Permissions flag: Bit to determine whether a file is executed as the
group owner
|
static int |
S_ISUID
Permissions flag: Bit to determine whether a file is executed as the
owner
|
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
basename(java.lang.String path)
Get the file portion of a path, i.e the part after the last /.
|
static void |
checkKnownHostsFile(SshConfiguration configuration)
Check the Known Hosts File parent directory exists,
creating it if it does.
|
static java.lang.String |
concatenatePaths(java.lang.String path,
java.lang.String filename)
Concatenate two paths, removing any additional leading/trailing slashes.
|
static boolean |
delTree(java.io.File file)
Recursively delete a file and all of it's children.
|
static java.lang.String |
dirname(java.lang.String remotePath)
Get the directory portion of a file path.
|
static java.lang.String |
escape(java.lang.String string,
char what,
java.lang.String with)
Process a string, replacing a specified character with another string.
|
static java.lang.String |
formatAsHexString(byte[] arr)
Format a byte array as a hex string.
|
static java.lang.String |
getConfigurationValue(SshConfiguration configuration,
java.lang.String name,
java.lang.String defaultValue)
Get a value from a configuration object, returning a default value if it
does not exist.
|
static java.io.File |
getKnownHostsFile(SshConfiguration configuration)
Get the file to load known host keys from given an
SshConfiguration. |
static java.lang.String |
getMaskString(int permissions)
Return the UNIX style mode mask
|
static java.lang.String |
getPermissionsString(int type,
long permissions)
Returns a formatted permissions string.
|
static java.lang.String |
guessKeyType(byte[] key)
Guess the type of
|
static void |
joinStreams(java.io.InputStream in,
java.io.OutputStream out)
Copy bytes read from an input stream to an output stream, until the end
of the input stream is reached.
|
static boolean |
nullOrTrimmedBlank(java.lang.String string)
Return an empty string if null, or a string with spaces trimmed from the
beginning and end if not null.
|
static byte[] |
parseHexString(java.lang.String string)
Parse a string of bytes encoded as hexadecimal values.
|
static long[] |
parsePermissionsString(java.lang.String perm)
Parse a formatted permissions string.
|
static java.lang.String |
prompt(java.lang.String message)
Prompt for an answer on the console
|
static java.lang.String |
prompt(java.lang.String message,
java.lang.String defaultValue)
Display a prompt on the console and wait for an answer.
|
static boolean |
promptYesNo(java.lang.String message)
Prompt for a yes / no answer on the console
|
static java.lang.String |
toDelimited(java.lang.String[] arr,
char delimiter)
Convert a string array into a delimited string.
|
public static final int S_IFMT
public static final int S_ISUID
public static final int S_ISGID
public static java.lang.String toDelimited(java.lang.String[] arr,
char delimiter)
arr - array of stringsdelimiter - delimiterpublic static boolean promptYesNo(java.lang.String message)
message - message to displaytrue for yes)public static java.lang.String prompt(java.lang.String message)
message - message to displaypublic static java.lang.String formatAsHexString(byte[] arr)
arr - byte arraypublic static java.lang.String prompt(java.lang.String message,
java.lang.String defaultValue)
message - message to display to usedefaultValue - value to return if user just presses RETURNpublic static java.lang.String basename(java.lang.String path)
path - pathpublic static java.lang.String concatenatePaths(java.lang.String path,
java.lang.String filename)
path - first path portionfilename - path to appendpublic static byte[] parseHexString(java.lang.String string)
string - hex stringpublic static void joinStreams(java.io.InputStream in,
java.io.OutputStream out)
throws java.io.IOException
in - input streamout - output streamjava.io.IOExceptionpublic static boolean nullOrTrimmedBlank(java.lang.String string)
string - public static java.lang.String getConfigurationValue(SshConfiguration configuration, java.lang.String name, java.lang.String defaultValue)
configuration - configuration objectname - name of configurationdefaultValue - public static java.io.File getKnownHostsFile(SshConfiguration configuration) throws SshException
SshConfiguration.configuration - SshExceptionpublic static boolean delTree(java.io.File file)
file - file to deletepublic static java.lang.String escape(java.lang.String string,
char what,
java.lang.String with)
string - string to replacewhat - character to replacewith - string to replace character withpublic static java.lang.String dirname(java.lang.String remotePath)
remotePath - pathpublic static java.lang.String getPermissionsString(int type,
long permissions)
SftpFile.TYPES.type - permissions - permissionspublic static long[] parsePermissionsString(java.lang.String perm)
SftpFile.TYPES.permissions - permissions stringpublic static java.lang.String getMaskString(int permissions)
permissions - permissionspublic static java.lang.String guessKeyType(byte[] key)
key - key - typeSshConfiguration.PUBLIC_KEY_SSHDSA or @
SshConfiguration.PUBLIC_KEY_SSHRSApublic static void checkKnownHostsFile(SshConfiguration configuration) throws SshException
configuration - SshExceptionCopyright © 2018. All rights reserved.