Package com.sshtools.common.util
Class Utils
java.lang.Object
com.sshtools.common.util.Utils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic Stringstatic Stringstatic Stringstatic StringbytesToHex(byte[] bytes) static StringbytesToHex(byte[] bytes, int bytesPerLine, boolean separateBytes, boolean showText) static StringbytesToHex(byte[] bytes, int off, int len) static StringbytesToHex(byte[] bytes, int off, int len, int bytesPerLine, boolean separateBytes, boolean showText) static Stringstatic Stringstatic Stringcsv(String separator, Collection<String> elements) static Stringcsv(Collection<String> elements) static StringdefaultString(String value, String defaultValue) static Optional<char[]>emptyOptionalIfBlank(char[] str) static StringencodeUserInfo(String userinfo) static Stringstatic StringformatHostnameAndPort(String hostname, int port) static StringgenerateThreadDump(Thread.State... states) From https://crunchify.com/how-to-generate-java-thread-dump-programmatically/static intstatic byte[]getUTF8Bytes(String str) static booleanstatic byte[]hexToBytes(String s) Converts a hex string to bytes.static booleanstatic booleanisNotBlank(String str) static Stringstatic StringmergeToArgsString(String[] args) static intnearestMultipleOf(int length, int i) static Stringpad(int num) static Stringprompt(BufferedReader reader, String message) static Stringprompt(BufferedReader reader, String message, String defaultValue) static StringrandomAlphaNumericString(int length) static Stringstatic String[]splitToArgsArray(String args) static byte[]stripLeadingZeros(byte[] data) static StringtranslatePathString(Path path)
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
before
-
after
-
after
-
before
-
bytesToHex
-
bytesToHex
-
bytesToHex
public static String bytesToHex(byte[] bytes, int bytesPerLine, boolean separateBytes, boolean showText) -
bytesToHex
public static String bytesToHex(byte[] bytes, int off, int len, int bytesPerLine, boolean separateBytes, boolean showText) -
stripLeadingZeros
public static byte[] stripLeadingZeros(byte[] data) -
nearestMultipleOf
public static int nearestMultipleOf(int length, int i) -
splitToArgsArray
-
generateThreadDump
From https://crunchify.com/how-to-generate-java-thread-dump-programmatically/- Returns:
-
isBlank
-
isNotBlank
-
mergeToArgsString
-
getUTF8Bytes
-
join
-
rightPad
-
defaultString
-
csv
-
csv
-
csv
-
csv
-
randomAlphaNumericString
-
exec
- Throws:
IOExceptionInterruptedException
-
prompt
- Throws:
IOException
-
prompt
public static String prompt(BufferedReader reader, String message, String defaultValue) throws IOException - Throws:
IOException
-
hasPort
-
formatHostnameAndPort
-
getPort
-
hexToBytes
Converts a hex string to bytes.- Parameters:
s- the hex string to be converted.- Returns:
- the byte[]
-
pad
-
emptyOptionalIfBlank
-
emptyOptionalIfBlank
-
translatePathString
-
encodeUserInfo
-