@ThreadSafe public final class WebFileIO extends Object
| Modifier and Type | Method and Description |
|---|---|
static com.helger.commons.state.ISuccessIndicator |
createDirectory(String sRelativePath,
boolean bRecursive)
Create the appropriate directory if it is not existing
|
static boolean |
existsDir(String sRelativePath)
Check if a directory relative to the base path exists
|
static boolean |
existsFile(String sRelativePath)
Check if a file relative to the base path exists
|
static String |
getBasePath() |
static File |
getBasePathFile() |
static IPathRelativeIO |
getDataIO() |
static File |
getFile(String sRelativePath)
Get a
File relative to the base path. |
static com.helger.commons.io.file.FileOperationManager |
getFileOpMgr() |
static InputStream |
getInputStream(String sRelativePath)
Get the
InputStream relative to the base path |
static OutputStream |
getOutputStream(String sRelativePath,
com.helger.commons.io.EAppend eAppend)
Get the
OutputStream relative to the base path |
static Reader |
getReader(String sRelativePath,
Charset aCharset)
Get the
Reader relative to the base path |
static String |
getRelativeFilename(File aAbsoluteFile)
Get the relative file name for the passed absolute file.
|
static com.helger.commons.io.resource.FileSystemResource |
getResource(String sRelativePath)
Get the file system resource relative to the base path
|
static IPathRelativeIO |
getServletContextIO() |
static Writer |
getWriter(String sRelativePath,
Charset aCharset,
com.helger.commons.io.EAppend eAppend)
Get the
Writer relative to the base path |
static void |
initPaths(File aDataPath,
File aServletContextPath,
boolean bCheckFileAccess) |
static boolean |
isInited() |
static void |
resetPaths()
Reset the base paths - no matter if they were initialized or not.
|
static void |
setFileOpMgr(com.helger.commons.io.file.FileOperationManager aFileOpMgr)
Set the global file operation manager to be used.
|
public static void setFileOpMgr(@Nonnull com.helger.commons.io.file.FileOperationManager aFileOpMgr)
aFileOpMgr - The file operation manager. May not be null.@Nonnull public static com.helger.commons.io.file.FileOperationManager getFileOpMgr()
null.public static void initPaths(@Nonnull File aDataPath, @Nonnull File aServletContextPath, boolean bCheckFileAccess)
public static void resetPaths()
public static boolean isInited()
true if the base path was initialized,
false otherwise@Nonnull public static IPathRelativeIO getDataIO()
IllegalStateException - if no servlet context path was provided@Nonnull public static IPathRelativeIO getServletContextIO()
IllegalStateException - if no servlet context path was provided@Nonnull public static File getBasePathFile()
IllegalStateException - if no base path was provided@Nonnull @Nonempty public static String getBasePath()
IllegalStateException - if no base path was provided@Nonnull public static File getFile(@Nonnull String sRelativePath)
File relative to the base path.sRelativePath - the relative pathFile and never null.IllegalStateException - if no base path was providedgetBasePathFile()public static boolean existsFile(@Nonnull String sRelativePath)
sRelativePath - the relative pathtrue if the File is a file and exists,
false otherwise.IllegalStateException - if no base path was providedgetBasePathFile()public static boolean existsDir(@Nonnull String sRelativePath)
sRelativePath - the relative pathtrue if the File is a directory and exists,
false otherwise.IllegalStateException - if no base path was providedgetBasePathFile()@Nonnull public static com.helger.commons.io.resource.FileSystemResource getResource(@Nonnull String sRelativePath)
sRelativePath - the relative pathFileSystemResource and never
null.IllegalStateException - if no base path was providedgetBasePathFile()@Nullable public static InputStream getInputStream(@Nonnull String sRelativePath)
InputStream relative to the base pathsRelativePath - the relative pathnull if the path does not existIllegalStateException - if no base path was providedgetBasePathFile()@Nullable public static Reader getReader(@Nonnull String sRelativePath, @Nonnull Charset aCharset)
Reader relative to the base pathsRelativePath - the relative pathaCharset - The charset to use. May not be null.null if the path does not existIllegalStateException - if no base path was providedgetBasePathFile()@Nullable public static OutputStream getOutputStream(@Nonnull String sRelativePath, @Nonnull com.helger.commons.io.EAppend eAppend)
OutputStream relative to the base pathsRelativePath - the relative patheAppend - Append or truncate mode. May not be null.null if the path is not writablegetBasePathFile()@Nullable public static Writer getWriter(@Nonnull String sRelativePath, @Nonnull Charset aCharset, @Nonnull com.helger.commons.io.EAppend eAppend)
Writer relative to the base pathsRelativePath - 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 writablegetBasePathFile()@Nonnull public static com.helger.commons.state.ISuccessIndicator createDirectory(@Nonnull String sRelativePath, boolean bRecursive)
sRelativePath - the relative pathbRecursive - if true all missing parent directories will be creatednull.getBasePathFile()Copyright © 2014–2015 Philip Helger. All rights reserved.