@Immutable public class PathRelativeFileIO extends Object implements IPathRelativeIO
IPathRelativeIO.| Constructor and Description |
|---|
PathRelativeFileIO(File aBasePath,
boolean bCheckAccessRights) |
| Modifier and Type | Method and Description |
|---|---|
com.helger.commons.state.ESuccess |
appendFile(String sFilename,
byte[] aBytes)
Helper function for saving a file with correct error handling.
|
com.helger.commons.state.ESuccess |
appendFile(String sFilename,
String sContent,
Charset aCharset)
Helper function for saving a file with correct error handling.
|
com.helger.commons.io.file.FileIOError |
createDirectory(String sRelativePath,
boolean bRecursive)
Create the appropriate directory if it is not existing
|
com.helger.commons.io.file.FileIOError |
deleteDirectory(File fDir,
boolean bDeleteRecursively) |
com.helger.commons.io.file.FileIOError |
deleteDirectory(String sDirName,
boolean bDeleteRecursively) |
com.helger.commons.io.file.FileIOError |
deleteDirectoryIfExisting(File fDir,
boolean bDeleteRecursively) |
com.helger.commons.io.file.FileIOError |
deleteDirectoryIfExisting(String sDirName,
boolean bDeleteRecursively) |
com.helger.commons.io.file.FileIOError |
deleteFile(File aFile) |
com.helger.commons.io.file.FileIOError |
deleteFile(String sFilename) |
com.helger.commons.io.file.FileIOError |
deleteFileIfExisting(File aFile) |
com.helger.commons.io.file.FileIOError |
deleteFileIfExisting(String sFilename) |
boolean |
equals(Object o) |
boolean |
existsDir(String sRelativePath)
Check if a directory relative to the base path exists
|
boolean |
existsFile(String sRelativePath)
Check if a file relative to the base path exists
|
String |
getBasePath() |
File |
getBasePathFile() |
File |
getFile(String sRelativePath)
Get a
File relative to the base path. |
protected com.helger.commons.io.file.FileOperationManager |
getFileOperationMgr() |
InputStream |
getInputStream(String sRelativePath)
Get the
InputStream relative to the base path |
OutputStream |
getOutputStream(String sRelativePath)
Get the
OutputStream relative to the base path. |
OutputStream |
getOutputStream(String sRelativePath,
com.helger.commons.io.EAppend eAppend)
Get the
OutputStream relative to the base path |
Reader |
getReader(String sRelativePath,
Charset aCharset)
Get the
Reader relative to the base path |
String |
getRelativeFilename(File aAbsoluteFile)
Get the relative file name for the passed absolute file.
|
com.helger.commons.io.resource.FileSystemResource |
getResource(String sRelativePath)
Get the file system resource relative to the base path
|
Writer |
getWriter(String sRelativePath,
Charset aCharset)
Get the
Writer relative to the base path. |
Writer |
getWriter(String sRelativePath,
Charset aCharset,
com.helger.commons.io.EAppend eAppend)
Get the
Writer relative to the base path. |
int |
hashCode() |
com.helger.commons.io.file.FileIOError |
renameDir(String sOldDirName,
String sNewDirName) |
com.helger.commons.io.file.FileIOError |
renameFile(String sOldFilename,
String sNewFilename) |
com.helger.commons.state.ESuccess |
saveFile(String sFilename,
byte[] aBytes)
Helper function for saving a file with correct error handling.
|
com.helger.commons.state.ESuccess |
saveFile(String sFilename,
String sContent,
Charset aCharset)
Helper function for saving a file with correct error handling.
|
String |
toString() |
@Nonnull @OverrideOnDemand protected com.helger.commons.io.file.FileOperationManager getFileOperationMgr()
@Nonnull public File getBasePathFile()
getBasePathFile in interface IPathRelativeIOnull.@Nonnull @Nonempty public String getBasePath()
getBasePath in interface IPathRelativeIOnull nor
empty.@Nonnull public File getFile(@Nonnull String sRelativePath)
IPathRelativeIOFile relative to the base path.getFile in interface IPathRelativeIOsRelativePath - the relative pathFile and never null.IPathRelativeIO.getBasePathFile()public boolean existsFile(@Nonnull String sRelativePath)
IPathRelativeIOexistsFile in interface IPathRelativeIOsRelativePath - the relative pathtrue if the File is a file and exists,
false otherwise.IPathRelativeIO.getBasePathFile()public boolean existsDir(@Nonnull String sRelativePath)
IPathRelativeIOexistsDir in interface IPathRelativeIOsRelativePath - the relative pathtrue if the File is a directory and exists,
false otherwise.IPathRelativeIO.getBasePathFile()@Nonnull public com.helger.commons.io.resource.FileSystemResource getResource(@Nonnull String sRelativePath)
IPathRelativeIOgetResource in interface IPathRelativeIOsRelativePath - the relative pathFileSystemResource and never
null.IPathRelativeIO.getBasePathFile()@Nullable public InputStream getInputStream(@Nonnull String sRelativePath)
IPathRelativeIOInputStream relative to the base pathgetInputStream in interface IPathRelativeIOsRelativePath - the relative pathnull if the path does not existIPathRelativeIO.getBasePathFile()@Nullable public Reader getReader(@Nonnull String sRelativePath, @Nonnull Charset aCharset)
IPathRelativeIOReader relative to the base pathgetReader in interface IPathRelativeIOsRelativePath - the relative pathaCharset - The charset to use. May not be null.null if the path does not existIPathRelativeIO.getBasePathFile()@Nullable public OutputStream getOutputStream(@Nonnull String sRelativePath)
IPathRelativeIOOutputStream relative to the base path. An eventually
existing file is truncated.getOutputStream in interface IPathRelativeIOsRelativePath - the relative pathnull if the path is not writableIPathRelativeIO.getBasePathFile()@Nullable public OutputStream getOutputStream(@Nonnull String sRelativePath, @Nonnull com.helger.commons.io.EAppend eAppend)
IPathRelativeIOOutputStream relative to the base pathgetOutputStream in interface IPathRelativeIOsRelativePath - the relative patheAppend - Append or truncate mode. May not be null.null if the path is not writableIPathRelativeIO.getBasePathFile()@Nullable public Writer getWriter(@Nonnull String sRelativePath, @Nonnull Charset aCharset)
IPathRelativeIOWriter relative to the base path. An eventually existing
file is truncated.getWriter in interface IPathRelativeIOsRelativePath - the relative pathaCharset - The charset to use. May not be null.null if the path is not writableIPathRelativeIO.getBasePathFile()@Nullable public Writer getWriter(@Nonnull String sRelativePath, @Nonnull Charset aCharset, @Nonnull com.helger.commons.io.EAppend eAppend)
IPathRelativeIOWriter relative to the base path.getWriter in interface IPathRelativeIOsRelativePath - the relative pathaCharset - The charset to use. May not be null.eAppend - Append or truncate mode. May not be null.null if the path is not writableIPathRelativeIO.getBasePathFile()@Nonnull public com.helger.commons.io.file.FileIOError createDirectory(@Nonnull String sRelativePath, boolean bRecursive)
IPathRelativeIOcreateDirectory in interface IPathRelativeIOsRelativePath - the relative pathbRecursive - if true all missing parent directories will be creatednull.IPathRelativeIO.getBasePathFile()@Nonnull public com.helger.commons.io.file.FileIOError deleteFile(@Nonnull String sFilename)
deleteFile in interface IPathRelativeIO@Nonnull public com.helger.commons.io.file.FileIOError deleteFile(@Nonnull File aFile)
deleteFile in interface IPathRelativeIO@Nonnull public com.helger.commons.io.file.FileIOError deleteFileIfExisting(@Nonnull String sFilename)
deleteFileIfExisting in interface IPathRelativeIO@Nonnull public com.helger.commons.io.file.FileIOError deleteFileIfExisting(@Nonnull File aFile)
deleteFileIfExisting in interface IPathRelativeIO@Nonnull public com.helger.commons.io.file.FileIOError deleteDirectory(@Nonnull String sDirName, boolean bDeleteRecursively)
deleteDirectory in interface IPathRelativeIO@Nonnull public com.helger.commons.io.file.FileIOError deleteDirectory(@Nonnull File fDir, boolean bDeleteRecursively)
deleteDirectory in interface IPathRelativeIO@Nonnull public com.helger.commons.io.file.FileIOError deleteDirectoryIfExisting(@Nonnull String sDirName, boolean bDeleteRecursively)
deleteDirectoryIfExisting in interface IPathRelativeIO@Nonnull public com.helger.commons.io.file.FileIOError deleteDirectoryIfExisting(@Nonnull File fDir, boolean bDeleteRecursively)
deleteDirectoryIfExisting in interface IPathRelativeIO@Nonnull public com.helger.commons.io.file.FileIOError renameFile(@Nonnull String sOldFilename, @Nonnull String sNewFilename)
renameFile in interface IPathRelativeIO@Nonnull public com.helger.commons.io.file.FileIOError renameDir(@Nonnull String sOldDirName, @Nonnull String sNewDirName)
renameDir in interface IPathRelativeIO@Nonnull public com.helger.commons.state.ESuccess saveFile(@Nonnull String sFilename, @Nonnull String sContent, @Nonnull Charset aCharset)
IPathRelativeIOsaveFile in interface IPathRelativeIOsFilename - name of the file. May not be null.sContent - the content to save. May not be null.aCharset - The character set to use. May not be null.ESuccess@Nonnull public com.helger.commons.state.ESuccess saveFile(@Nonnull String sFilename, @Nonnull byte[] aBytes)
IPathRelativeIOsaveFile in interface IPathRelativeIOsFilename - name of the file. May not be null.aBytes - the bytes to be written. May not be null.ESuccess@Nonnull public com.helger.commons.state.ESuccess appendFile(@Nonnull String sFilename, @Nonnull String sContent, @Nonnull Charset aCharset)
IPathRelativeIOappendFile in interface IPathRelativeIOsFilename - name of the file. May not be null.sContent - the content to save. May not be null.aCharset - The character set to use. May not be null.ESuccess@Nonnull public com.helger.commons.state.ESuccess appendFile(@Nonnull String sFilename, @Nonnull byte[] aBytes)
IPathRelativeIOappendFile in interface IPathRelativeIOsFilename - name of the file. May not be null.aBytes - the bytes to be written. May not be null.ESuccess@Nullable public String getRelativeFilename(@Nonnull File aAbsoluteFile)
IPathRelativeIOgetRelativeFilename in interface IPathRelativeIOaAbsoluteFile - The non-null absolute file to make relative.null if the passed file is not a child of this base
directory.Copyright © 2014–2015 Philip Helger. All rights reserved.