java.lang.Object
org.apache.jena.atlas.io.IOX
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRun I/O codestatic interfaceA Consumer that can throwIOException. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidCopy a file, not atomic. * Can copy to a directory or over an existing file.static voidcreateDirectory(Path dir) Create a directory - throw a runtime exception if there are any problems.static PathcreateTempFile(Path dir, String prefix, String suffix, FileAttribute<?>... attrs) Return a temporary filename path.static voidDelete a file.static voidstatic voidDelete everything from aPathstart point, including the path itself.static RuntimeIOExceptionexception(IOException ioException) Convert anIOExceptioninto aRuntimeIOException.static RuntimeIOExceptionexception(String message, IOException ioException) Convert anIOExceptioninto aRuntimeIOException.static voidAtomically move a file.static voidmoveAllowCopy(Path src, Path dst) Move a file, allowing the system to copy-delete it if it can not be moved atomically.static byte[]Read the whole of a filestatic voidrun(IOX.ActionIO action) Run an action, converting anIOExceptioninto aRuntimeIOException.static booleansafeWrite(Path file, Path tmpFile, IOX.IOConsumer<OutputStream> writerAction) Write a file safely - the change happens (the function returns true) or something went wrong (the function throws a runtime exception) and the file is not changed.static booleansafeWrite(Path file, IOX.IOConsumer<OutputStream> writerAction) Write a file safely - the change happens (the function returns true) or something went wrong (the function throws a runtime exception) and the file is not changed.static booleansafeWriteOrCopy(Path file, Path tmpFile, IOX.IOConsumer<OutputStream> writerAction) Write a file safely, but allow system to use copy-delete if the change can not be done atomically.static PathuniqueDerivedPath(Path path, Function<String, String> basenameMapping) Generate a unique place related to path; Optionally, provide a mapping of old name to new namebase.static voidWrite the whole of a file
-
Field Details
-
currentDirectory
-
-
Constructor Details
-
IOX
public IOX()
-
-
Method Details
-
exception
Convert anIOExceptioninto aRuntimeIOException.Idiom:
catch(IOException ex) { throw new exception(ex); }- Parameters:
ioException-- Returns:
- RuntimeIOException
-
exception
Convert anIOExceptioninto aRuntimeIOException.Idiom:
catch(IOException ex) { throw new exception("Oh dear", ex); }- Parameters:
message-ioException-- Returns:
- RuntimeIOException
-
run
-
safeWrite
Write a file safely - the change happens (the function returns true) or something went wrong (the function throws a runtime exception) and the file is not changed. -
safeWrite
Write a file safely - the change happens (the function returns true) or something went wrong (the function throws a runtime exception) and the file is not changed. Note that the tmpfile must be in the same directory as the actual file so an OS-atomic rename can be done. -
safeWriteOrCopy
public static boolean safeWriteOrCopy(Path file, Path tmpFile, IOX.IOConsumer<OutputStream> writerAction) Write a file safely, but allow system to use copy-delete if the change can not be done atomically. PrefersafeWrite(java.nio.file.Path, org.apache.jena.atlas.io.IOX.IOConsumer<java.io.OutputStream>)which requires an atomic move. -
delete
Delete a file. -
move
Atomically move a file. -
moveAllowCopy
Move a file, allowing the system to copy-delete it if it can not be moved atomically. -
deleteAll
-
deleteAll
Delete everything from aPathstart point, including the path itself. Works on files or directories. Walks down the tree and deletes directories on the way backup. -
copy
Copy a file, not atomic. * Can copy to a directory or over an existing file.- Parameters:
srcFilename-dstFilename-
-
createDirectory
Create a directory - throw a runtime exception if there are any problems. This function wrapsFiles.createDirectory. -
readAll
Read the whole of a file -
writeAll
Write the whole of a file -
createTempFile
public static Path createTempFile(Path dir, String prefix, String suffix, FileAttribute<?>... attrs) Return a temporary filename path.This operation is thread-safe.
-
uniqueDerivedPath
Generate a unique place related to path; Optionally, provide a mapping of old name to new namebase. This method always adds "-1", "-2" etc.
-