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. -
fileAttributesFromInteger
Create NIO file attributes from numerical POSIX permissions. -
fileKey
Return a unique string identifying the given file object.- Throws:
IOException
-
fileKey
Return a unique string identifying the given path string.- Throws:
IOException
-
fileKey
Return a unique string identifying the given path object.- Throws:
IOException
-
writeToFile
Write a UTF-8 string to a file object.- Throws:
IOException
-
writeToFile
Write a UTF-8 string to a path string.- Throws:
IOException
-
writeToFile
Write a UTF-8 string to a path object.- Throws:
IOException
-
writeToFile
Write bytes to a file object.- Throws:
IOException
-
writeToFile
Write bytes to a path string.- Throws:
IOException
-
writeToFile
Write bytes to a path object.- Throws:
IOException
-
readToString
Read a UTF-8 string from a file object.- Throws:
IOException
-
readToString
Read a UTF-8 string from a path string.- Throws:
IOException
-
readToString
Read a UTF-8 string from a path object.- Throws:
IOException
-
readToByteArray
Read all the bytes from a file object.- Throws:
IOException
-
readToByteArray
Read all the bytes from a path string.- Throws:
IOException
-
readToByteArray
Read all the bytes from a path object.- Throws:
IOException
-
recursiveDelete
Recursively delete the given path, stopping on the first error.
-