public class Utils
extends java.lang.Object
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areFilesIdentical(java.lang.String file1Path,
java.lang.String file2Path)
Compares two files to determine if they are identical
|
static java.lang.String |
byteBufferToString(java.nio.ByteBuffer buffer)
Converts a ByteBuffer to a UTF-8 encoded string
|
static java.lang.String |
bytesToHex(byte[] bytes)
Converts a byte array to a hexadecimal string
|
static byte[] |
byteStringToByteArray(java.lang.String byteString)
Converts a string to a byte array where each character is converted to a byte
|
static void |
cleanDirectBuffer(java.nio.ByteBuffer buffer)
Cleans a direct ByteBuffer by setting it to null and invoking garbage collection
|
static void |
deleteAllFile(java.lang.String filePath)
Deletes all files in the directory that start with the specified file name
|
static java.lang.String |
formatTimestamp(long timestamp,
java.lang.String pattern)
Formats a timestamp into a string based on the given pattern
|
static byte[] |
hexStringToByteArray(java.lang.String s)
Converts a hexadecimal string to a byte array
|
static boolean |
isNullOrEmpty(java.lang.String str)
Checks if a string is null or empty
|
static java.lang.String |
readFile(java.lang.String filePath)
Reads the content of a file into a string
|
public static boolean isNullOrEmpty(java.lang.String str)
str - Input stringpublic static void cleanDirectBuffer(java.nio.ByteBuffer buffer)
buffer - The ByteBuffer to cleanpublic static java.lang.String bytesToHex(byte[] bytes)
bytes - Input byte arraypublic static byte[] hexStringToByteArray(java.lang.String s)
s - Hexadecimal stringpublic static byte[] byteStringToByteArray(java.lang.String byteString)
byteString - Input stringpublic static java.lang.String byteBufferToString(java.nio.ByteBuffer buffer)
buffer - The ByteBuffer to convertpublic static boolean areFilesIdentical(java.lang.String file1Path,
java.lang.String file2Path)
file1Path - Path to the first filefile2Path - Path to the second filepublic static void deleteAllFile(java.lang.String filePath)
filePath - Path to the file whose directory will be cleanedpublic static java.lang.String readFile(java.lang.String filePath)
filePath - Path to the filepublic static java.lang.String formatTimestamp(long timestamp,
java.lang.String pattern)
timestamp - The timestamp to formatpattern - The pattern to format the timestamp