Package ch.cern.dirq
Class FileUtils
java.lang.Object
ch.cern.dirq.FileUtils
Convenient file related utilities.
This is a private class to be used only by the directory queue classes. Its API can change at any time without any notice.
This is a private class to be used only by the directory queue classes. Its API can change at any time without any notice.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FileAttribute
<?> fileAttributesFromInteger
(int perm) Create NIO file attributes from numerical POSIX permissions.static String
Return a unique string identifying the given file object.static String
Return a unique string identifying the given path string.static String
Return a unique string identifying the given path object.private static boolean
isSet
(int perm, int bit) static Set
<PosixFilePermission> posixPermissionsFromInteger
(int perm) Create NIO POSIX file permissions from numerical POSIX permissions.static byte[]
readToByteArray
(File file) Read all the bytes from a file object.static byte[]
readToByteArray
(String path) Read all the bytes from a path string.static byte[]
readToByteArray
(Path path) Read all the bytes from a path object.static String
readToString
(File file) Read a UTF-8 string from a file object.static String
readToString
(String path) Read a UTF-8 string from a path string.static String
readToString
(Path path) Read a UTF-8 string from a path object.static boolean
recursiveDelete
(File path) Recursively delete the given path, stopping on the first error.static void
writeToFile
(File file, byte[] data) Write bytes to a file object.static void
writeToFile
(File file, String data) Write a UTF-8 string to a file object.static void
writeToFile
(String path, byte[] data) Write bytes to a path string.static void
writeToFile
(String path, String data) Write a UTF-8 string to a path string.static void
writeToFile
(Path path, byte[] data) Write bytes to a path object.static void
writeToFile
(Path path, String data) Write a UTF-8 string to a path object.
-
Field Details
-
S_IRWXU
public static final int S_IRWXU- See Also:
-
S_IRUSR
public static final int S_IRUSR- See Also:
-
S_IWUSR
public static final int S_IWUSR- See Also:
-
S_IXUSR
public static final int S_IXUSR- See Also:
-
S_IRWXG
public static final int S_IRWXG- See Also:
-
S_IRGRP
public static final int S_IRGRP- See Also:
-
S_IWGRP
public static final int S_IWGRP- See Also:
-
S_IXGRP
public static final int S_IXGRP- See Also:
-
S_IRWXO
public static final int S_IRWXO- See Also:
-
S_IROTH
public static final int S_IROTH- See Also:
-
S_IWOTH
public static final int S_IWOTH- See Also:
-
S_IXOTH
public static final int S_IXOTH- See Also:
-
-
Constructor Details
-
FileUtils
private FileUtils()
-
-
Method Details
-
isSet
private static boolean isSet(int perm, int bit) -
posixPermissionsFromInteger
Create NIO POSIX file permissions from numerical POSIX permissions.- Parameters:
perm
- numerical permissions- Returns:
- file permissions
-
fileAttributesFromInteger
Create NIO file attributes from numerical POSIX permissions.- Parameters:
perm
- numerical permissions- Returns:
- file attributes
-
fileKey
Return a unique string identifying the given file object.- Parameters:
file
- file object- Returns:
- unique string
- Throws:
IOException
- if any file operation fails
-
fileKey
Return a unique string identifying the given path string.- Parameters:
path
- file path string- Returns:
- unique string
- Throws:
IOException
- if any file operation fails
-
fileKey
Return a unique string identifying the given path object.- Parameters:
path
- file path object- Returns:
- unique string
- Throws:
IOException
- if any file operation fails
-
writeToFile
Write a UTF-8 string to a file object.- Parameters:
file
- file objectdata
- UTF-8 string- Throws:
IOException
- if any file operation fails
-
writeToFile
Write a UTF-8 string to a path string.- Parameters:
path
- file path stringdata
- UTF-8 string- Throws:
IOException
- if any file operation fails
-
writeToFile
Write a UTF-8 string to a path object.- Parameters:
path
- file path objectdata
- UTF-8 string- Throws:
IOException
- if any file operation fails
-
writeToFile
Write bytes to a file object.- Parameters:
file
- file objectdata
- bytes- Throws:
IOException
- if any file operation fails
-
writeToFile
Write bytes to a path string.- Parameters:
path
- file path stringdata
- bytes- Throws:
IOException
- if any file operation fails
-
writeToFile
Write bytes to a path object.- Parameters:
path
- file path objectdata
- bytes- Throws:
IOException
- if any file operation fails
-
readToString
Read a UTF-8 string from a file object.- Parameters:
file
- file object- Returns:
- UTF-8 string
- Throws:
IOException
- if any file operation fails
-
readToString
Read a UTF-8 string from a path string.- Parameters:
path
- file path string- Returns:
- UTF-8 string
- Throws:
IOException
- if any file operation fails
-
readToString
Read a UTF-8 string from a path object.- Parameters:
path
- file path object- Returns:
- UTF-8 string
- Throws:
IOException
- if any file operation fails
-
readToByteArray
Read all the bytes from a file object.- Parameters:
file
- file object- Returns:
- bytes
- Throws:
IOException
- if any file operation fails
-
readToByteArray
Read all the bytes from a path string.- Parameters:
path
- file path string- Returns:
- bytes
- Throws:
IOException
- if any file operation fails
-
readToByteArray
Read all the bytes from a path object.- Parameters:
path
- file path object- Returns:
- bytes
- Throws:
IOException
- if any file operation fails
-
recursiveDelete
Recursively delete the given path, stopping on the first error.- Parameters:
path
- file object- Returns:
- true if delete succeeded
-