Package io.strimzi.kafka.oauth.common
Class IOUtil
java.lang.Object
io.strimzi.kafka.oauth.common.IOUtil
A helper class that contains commonly used methods for I/O operations
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringasHexString(byte[] bytes) Convert a byte array into a hexadecimal stringstatic voidcopy(InputStream input, OutputStream output) Copy the content of specified InputStream into the specified OutputStreamstatic longCalculate a CRC32 for the specified Stringstatic StringhashForObjects(Object... args) Generate a predictable (deterministic) hash string of length 8 for an array of objectsstatic booleanCheck that there are minimal permissions on the file (owner access only)static StringGenerate a random 8 character string of hexadecimal digitsstatic StringrandomHexString(int length) Generate a random string of hexadecimal digits of the specified length
-
Constructor Details
-
IOUtil
public IOUtil()
-
-
Method Details
-
copy
Copy the content of specified InputStream into the specified OutputStream- Parameters:
input- The input stream to read fromoutput- The output stream to write to- Throws:
IOException- an exception if the copy operation fails
-
randomHexString
Generate a random 8 character string of hexadecimal digits- Returns:
- a hexadecimal String of length 8
-
randomHexString
Generate a random string of hexadecimal digits of the specified length- Parameters:
length- The length of the resulting string- Returns:
- a hexadecimal String of the specified length
-
asHexString
Convert a byte array into a hexadecimal string- Parameters:
bytes- A byte array- Returns:
- a hexadecimal string
-
hashForObjects
Generate a predictable (deterministic) hash string of length 8 for an array of objects- Parameters:
args- The objects to take as input for the calculation- Returns:
- a hash string of length 8
-
crc32
Calculate a CRC32 for the specified String- Parameters:
content- The input string- Returns:
- CRC32 as long value
-
isFileAccessLimitedToOwner
Check that there are minimal permissions on the file (owner access only)In POSIX compatible environment there should be no permissions for group and other users. In ACL compatible environment there should be no permissions for anyone other than current user, Administrators or SYSTEM.
- Parameters:
file- Path object representing an existing file to check file permissions for- Returns:
trueif file permissions limit access to this file to the owner- Throws:
IllegalArgumentException- if file doesn't exist or is not a regular file (not a directory)UnsupportedOperationException- if filesystem doesn't support POSIX or ACL file permissionsIOException- if an I/O error occurs
-