Package com.helger.commons.io.relative
Interface IFileRelativeIO
- All Superinterfaces:
IPathRelativeIO
- All Known Implementing Classes:
FileRelativeIO
An extended
IPathRelativeIO version that uses files as the basis.- Since:
- 7.1.1
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptiondefault ESuccessappendFile(String sRelativePath, byte[] aBytes) Helper function for saving a file with correct error handling.default ESuccessappendFile(String sRelativePath, String sContent, Charset aCharset) Helper function for saving a file with correct error handling.default FileIOErrorcreateDirectory(String sRelativePath, boolean bRecursive) Create the appropriate directory if it is not existingdefault FileIOErrordeleteDirectory(String sRelativePath, boolean bDeleteRecursively) default FileIOErrordeleteDirectoryIfExisting(String sRelativePath, boolean bDeleteRecursively) default FileIOErrordeleteFile(String sRelativePath) default FileIOErrordeleteFileIfExisting(String sRelativePath) default booleanCheck if a directory relative to the base path existsdefault booleanexistsFile(String sRelativePath) Check if a file relative to the base path existsdefault Stringdefault FileGet aFilerelative to the base path.default OutputStreamgetOutputStream(String sRelativePath) Get theOutputStreamrelative to the base path.default OutputStreamgetOutputStream(String sRelativePath, EAppend eAppend) Get theOutputStreamrelative to the base pathdefault StringgetRelativeFilename(File aAbsoluteFile) Get the relative file name for the passed absolute file.default FileSystemResourcegetResource(String sRelativePath) Get the file system resource relative to the base pathdefault WriterGet theWriterrelative to the base path.default WriterGet theWriterrelative to the base path.default FileIOErrordefault FileIOErrorrenameFile(String sOldFilename, String sNewFilename) default ESuccessHelper function for saving a file with correct error handling.default ESuccessHelper function for saving a file with correct error handling.default ESuccessHelper function for saving a file with correct error handling.Methods inherited from interface com.helger.commons.io.relative.IPathRelativeIO
getInputStream, getReader
-
Method Details
-
getBasePathFile
- Returns:
- The base path. Never
null.
-
getBasePath
- Specified by:
getBasePathin interfaceIPathRelativeIO- Returns:
- The absolute base path that is used. Neither
nullnor empty.
-
getFile
Get aFilerelative to the base path.- Parameters:
sRelativePath- the relative path- Returns:
- The "absolute"
Fileand nevernull. - See Also:
-
getResource
Get the file system resource relative to the base path- Specified by:
getResourcein interfaceIPathRelativeIO- Parameters:
sRelativePath- the relative path- Returns:
- The "absolute"
FileSystemResourceand nevernull. - See Also:
-
getRelativeFilename
Get the relative file name for the passed absolute file.- Parameters:
aAbsoluteFile- The non-nullabsolute file to make relative.- Returns:
nullif the passed file is not a child of this base directory.
-
existsFile
Check if a file relative to the base path exists- Parameters:
sRelativePath- the relative path- Returns:
trueif theFileis a file and exists,falseotherwise.- See Also:
-
existsDir
Check if a directory relative to the base path exists- Parameters:
sRelativePath- the relative path- Returns:
trueif theFileis a directory and exists,falseotherwise.- See Also:
-
getOutputStream
Get theOutputStreamrelative to the base path. An eventually existing file is truncated.- Parameters:
sRelativePath- the relative path- Returns:
nullif the path is not writable- See Also:
-
getOutputStream
@Nullable default OutputStream getOutputStream(@Nonnull String sRelativePath, @Nonnull EAppend eAppend) Get theOutputStreamrelative to the base path- Parameters:
sRelativePath- the relative patheAppend- Append or truncate mode. May not benull.- Returns:
nullif the path is not writable- See Also:
-
getWriter
Get theWriterrelative to the base path. An eventually existing file is truncated.- Parameters:
sRelativePath- the relative pathaCharset- The charset to use. May not benull.- Returns:
nullif the path is not writable- See Also:
-
getWriter
@Nullable default Writer getWriter(@Nonnull String sRelativePath, @Nonnull Charset aCharset, @Nonnull EAppend eAppend) Get theWriterrelative to the base path.- Parameters:
sRelativePath- the relative pathaCharset- The charset to use. May not benull.eAppend- Append or truncate mode. May not benull.- Returns:
nullif the path is not writable- See Also:
-
createDirectory
Create the appropriate directory if it is not existing- Parameters:
sRelativePath- the relative pathbRecursive- iftrueall missing parent directories will be created- Returns:
- Success indicator. Never
null. - See Also:
-
deleteDirectory
@Nonnull default FileIOError deleteDirectory(@Nonnull String sRelativePath, boolean bDeleteRecursively) -
deleteDirectoryIfExisting
@Nonnull default FileIOError deleteDirectoryIfExisting(@Nonnull String sRelativePath, boolean bDeleteRecursively) -
deleteFile
-
deleteFileIfExisting
-
renameDir
-
renameFile
-
writeFile
@Nonnull default ESuccess writeFile(@Nonnull String sRelativePath, @Nonnull EAppend eAppend, @Nonnull byte[] aBytes) Helper function for saving a file with correct error handling.- Parameters:
sRelativePath- name of the file. May not benull.eAppend- Appending mode. May not benull.aBytes- the bytes to be written. May not benull.- Returns:
ESuccess
-
saveFile
@Nonnull default ESuccess saveFile(@Nonnull String sRelativePath, @Nonnull String sContent, @Nonnull Charset aCharset) Helper function for saving a file with correct error handling.- Parameters:
sRelativePath- name of the file. May not benull.sContent- the content to save. May not benull.aCharset- The character set to use. May not benull.- Returns:
ESuccess
-
saveFile
Helper function for saving a file with correct error handling.- Parameters:
sRelativePath- name of the file. May not benull.aBytes- the bytes to be written. May not benull.- Returns:
ESuccess
-
appendFile
@Nonnull default ESuccess appendFile(@Nonnull String sRelativePath, @Nonnull String sContent, @Nonnull Charset aCharset) Helper function for saving a file with correct error handling.- Parameters:
sRelativePath- name of the file. May not benull.sContent- the content to save. May not benull.aCharset- The character set to use. May not benull.- Returns:
ESuccess
-
appendFile
Helper function for saving a file with correct error handling.- Parameters:
sRelativePath- name of the file. May not benull.aBytes- the bytes to be written. May not benull.- Returns:
ESuccess
-