Package com.helger.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 @NonNull com.helger.base.state.ESuccessappendFile(@NonNull String sRelativePath, byte @NonNull [] aBytes) Helper function for saving a file with correct error handling.default @NonNull com.helger.base.state.ESuccessappendFile(@NonNull String sRelativePath, @NonNull String sContent, @NonNull Charset aCharset) Helper function for saving a file with correct error handling.default @NonNull FileIOErrorcreateDirectory(@NonNull String sRelativePath, boolean bRecursive) Create the appropriate directory if it is not existingdefault @NonNull FileIOErrordeleteDirectory(@NonNull String sRelativePath, boolean bDeleteRecursively) Delete a directory relative to the base path.default @NonNull FileIOErrordeleteDirectoryIfExisting(@NonNull String sRelativePath, boolean bDeleteRecursively) Delete a directory relative to the base path if it exists.default @NonNull FileIOErrordeleteFile(@NonNull String sRelativePath) Delete a file relative to the base path.default @NonNull FileIOErrordeleteFileIfExisting(@NonNull String sRelativePath) Delete a file relative to the base path if it exists.default booleanCheck if a directory relative to the base path existsdefault booleanexistsFile(@NonNull String sRelativePath) Check if a file relative to the base path existsdefault @NonNull @Nonempty String@NonNull Filedefault @NonNull FileGet aFilerelative to the base path.default @Nullable OutputStreamgetOutputStream(@NonNull String sRelativePath) Get theOutputStreamrelative to the base path.default @Nullable OutputStreamgetOutputStream(@NonNull String sRelativePath, @NonNull com.helger.base.io.EAppend eAppend) Get theOutputStreamrelative to the base pathdefault @Nullable StringgetRelativeFilename(@NonNull File aAbsoluteFile) Get the relative file name for the passed absolute file.default @NonNull FileSystemResourcegetResource(@NonNull String sRelativePath) Get the file system resource relative to the base pathdefault @Nullable WriterGet theWriterrelative to the base path.default @Nullable WritergetWriter(@NonNull String sRelativePath, @NonNull Charset aCharset, @NonNull com.helger.base.io.EAppend eAppend) Get theWriterrelative to the base path.default @NonNull FileIOErrorRename a directory relative to the base path.default @NonNull FileIOErrorrenameFile(@NonNull String sOldFilename, @NonNull String sNewFilename) Rename a file relative to the base path.default @NonNull com.helger.base.state.ESuccessHelper function for saving a file with correct error handling.default @NonNull com.helger.base.state.ESuccessHelper function for saving a file with correct error handling.default @NonNull com.helger.base.state.ESuccesswriteFile(@NonNull String sRelativePath, @NonNull com.helger.base.io.EAppend eAppend, byte @NonNull [] aBytes) Helper function for saving a file with correct error handling.Methods inherited from interface com.helger.io.relative.IPathRelativeIO
getInputStream, getReader
-
Method Details
-
getBasePathFile
@NonNull File 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
default @Nullable OutputStream getOutputStream(@NonNull String sRelativePath, @NonNull com.helger.base.io.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
default @Nullable Writer getWriter(@NonNull String sRelativePath, @NonNull Charset aCharset, @NonNull com.helger.base.io.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
default @NonNull FileIOError deleteDirectory(@NonNull String sRelativePath, boolean bDeleteRecursively) Delete a directory relative to the base path.- Parameters:
sRelativePath- The relative path of the directory. May not benull.bDeleteRecursively-trueto delete recursively,falseto delete only if empty.- Returns:
- The operation result. Never
null. - See Also:
-
deleteDirectoryIfExisting
default @NonNull FileIOError deleteDirectoryIfExisting(@NonNull String sRelativePath, boolean bDeleteRecursively) Delete a directory relative to the base path if it exists.- Parameters:
sRelativePath- The relative path of the directory. May not benull.bDeleteRecursively-trueto delete recursively,falseto delete only if empty.- Returns:
- The operation result. Never
null. - See Also:
-
deleteFile
Delete a file relative to the base path.- Parameters:
sRelativePath- The relative path of the file. May not benull.- Returns:
- The operation result. Never
null. - See Also:
-
deleteFileIfExisting
Delete a file relative to the base path if it exists.- Parameters:
sRelativePath- The relative path of the file. May not benull.- Returns:
- The operation result. Never
null. - See Also:
-
renameDir
Rename a directory relative to the base path.- Parameters:
sOldDirName- The old directory name. May not benull.sNewDirName- The new directory name. May not benull.- Returns:
- The operation result. Never
null. - See Also:
-
renameFile
Rename a file relative to the base path.- Parameters:
sOldFilename- The old filename. May not benull.sNewFilename- The new filename. May not benull.- Returns:
- The operation result. Never
null. - See Also:
-
writeFile
default @NonNull com.helger.base.state.ESuccess writeFile(@NonNull String sRelativePath, @NonNull com.helger.base.io.EAppend eAppend, byte @NonNull [] 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
default @NonNull com.helger.base.state.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
default @NonNull com.helger.base.state.ESuccess saveFile(@NonNull String sRelativePath, byte[] aBytes) 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
default @NonNull com.helger.base.state.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
default @NonNull com.helger.base.state.ESuccess appendFile(@NonNull String sRelativePath, byte @NonNull [] aBytes) 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
-