public class IOUtil
extends java.lang.Object
| Constructor and Description |
|---|
IOUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
asHexString(byte[] bytes)
Convert a byte array into a hexadecimal string
|
static void |
copy(java.io.InputStream input,
java.io.OutputStream output)
Copy the content of specified InputStream into the specified OutputStream
|
static long |
crc32(java.lang.String content)
Calculate a CRC32 for the specified String
|
static java.lang.String |
hashForObjects(java.lang.Object... args)
Generate a predictable (deterministic) hash string of length 8 for an array of objects
|
static boolean |
isFileAccessLimitedToOwner(java.nio.file.Path file)
Check that there are minimal permissions on the file (owner access only)
|
static java.lang.String |
randomHexString()
Generate a random 8 character string of hexadecimal digits
|
static java.lang.String |
randomHexString(int length)
Generate a random string of hexadecimal digits of the specified length
|
public static void copy(java.io.InputStream input,
java.io.OutputStream output)
throws java.io.IOException
input - The input stream to read fromoutput - The output stream to write tojava.io.IOException - an exception if the copy operation failspublic static java.lang.String randomHexString()
public static java.lang.String randomHexString(int length)
length - The length of the resulting stringpublic static java.lang.String asHexString(byte[] bytes)
bytes - A byte arraypublic static java.lang.String hashForObjects(java.lang.Object... args)
args - The objects to take as input for the calculationpublic static long crc32(java.lang.String content)
content - The input stringpublic static boolean isFileAccessLimitedToOwner(java.nio.file.Path file)
throws java.io.IOException
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.
file - Path object representing an existing file to check file permissions fortrue if file permissions limit access to this file to the ownerjava.lang.IllegalArgumentException - if file doesn't exist or is not a regular file (not a directory)java.lang.UnsupportedOperationException - if filesystem doesn't support POSIX or ACL file permissionsjava.io.IOException - if an I/O error occursCopyright © 2024. All rights reserved.