Class FileSystem
java.lang.Object
org.apache.commons.configuration2.io.FileSystem
- Direct Known Subclasses:
DefaultFileSystem
Abstract layer to allow various types of file systems.
- Since:
- 1.7
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract String
getBasePath
(String path) Gets the base path of the given path, for example a directory for a file.abstract String
getFileName
(String path) Gets the file name of the given path.Gets the FileSystem options provider.abstract InputStream
getInputStream
(URL url) Gets an input stream for a URL.getInputStream
(URL url, URLConnectionOptions urlConnectionOptions) Not abstract for binary compatibility.Gets the logger used by this FileSystem.abstract OutputStream
getOutputStream
(File file) Gets an output stream for a File.abstract OutputStream
getOutputStream
(URL url) Gets an output stream for a URL.abstract String
Gets a path string for the given input where some values may be null.abstract URL
Gets a URL for a base path and file name.abstract URL
locateFromURL
(String basePath, String fileName) Locates a URL for a base path and file name.void
setFileOptionsProvider
(FileOptionsProvider provider) Sets the FileOptionsProvidervoid
Sets the logger to be used by this FileSystem.
-
Constructor Details
-
FileSystem
public FileSystem()
-
-
Method Details
-
getBasePath
Gets the base path of the given path, for example a directory for a file.- Parameters:
path
- the source path.- Returns:
- the base path.
-
getFileName
Gets the file name of the given path.- Parameters:
path
- the source path.- Returns:
- the file name.
-
getFileOptionsProvider
Gets the FileSystem options provider.- Returns:
- the FileSystem options provider.
-
getInputStream
Gets an input stream for a URL.- Parameters:
url
- the source URL.- Returns:
- an input stream.
- Throws:
ConfigurationException
- if an problem occurs getting the input stream.
-
getInputStream
public InputStream getInputStream(URL url, URLConnectionOptions urlConnectionOptions) throws ConfigurationException Not abstract for binary compatibility.- Parameters:
url
- TODOurlConnectionOptions
- Ignored.- Returns:
- TODO
- Throws:
ConfigurationException
- TODO- Since:
- 2.8.0
-
getLogger
Gets the logger used by this FileSystem.- Returns:
- the logger
-
getOutputStream
Gets an output stream for a File.- Parameters:
file
- the source File.- Returns:
- an output stream.
- Throws:
ConfigurationException
- if an problem occurs getting the output stream.
-
getOutputStream
Gets an output stream for a URL.- Parameters:
url
- the source URL.- Returns:
- an output stream.
- Throws:
ConfigurationException
- if an problem occurs getting the output stream.
-
getPath
Gets a path string for the given input where some values may be null.The implementation decides on which argument take precedence.
- Parameters:
file
- A file.url
- A URL.basePath
- A base path string.fileName
- A file name.- Returns:
- A path string.
-
getURL
Gets a URL for a base path and file name.- Parameters:
basePath
- The base path.fileName
- The file name.- Returns:
- a URL.
- Throws:
MalformedURLException
- if a problem occurs creating the URL.
-
locateFromURL
Locates a URL for a base path and file name.- Parameters:
basePath
- The base path.fileName
- The file name.- Returns:
- a URL.
-
setFileOptionsProvider
Sets the FileOptionsProvider- Parameters:
provider
- The FileOptionsProvider
-
setLogger
Sets the logger to be used by this FileSystem. This method makes it possible for clients to exactly control logging behavior. Per default a logger is set that will ignore all log messages. Derived classes that want to enable logging should call this method during their initialization with the logger to be used. Passing in a null argument disables logging.- Parameters:
log
- the new logger
-