Package org.basex.io
Class IOFile
java.lang.Object
org.basex.io.IO
org.basex.io.IOFile
IO reference, representing a local file or directory path.- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
FieldsFields inherited from class org.basex.io.IO
BASEXSUFFIX, BLOCKSIZE, BXSSUFFIX, CSVSUFFIX, ENTRIES, FILEPREF, GZSUFFIX, HTMLSUFFIXES, IGNORESUFFIX, JARSUFFIX, JSONSUFFIX, JSSUFFIXES, len, LOGSUFFIX, MAXATTS, NODEPOWER, NODESIZE, pth, RAW, TARGZSUFFIX, TARSUFFIX, TGZSUFFIX, TMPSUFFIX, TXTSUFFIXES, XARSUFFIX, XMLSUFFIX, XQMSUFFIX, XQSUFFIX, XQSUFFIXES, XSLSUFFIXES, ZIPSUFFIX, ZIPSUFFIXES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIOFile[]children()Returns the children of the path.IOFile[]children(FileFilter filter) Returns the children of the path that match the specified filter.IOFile[]Returns the children of the path that match the specified regular expression.voidCopies a file to another target.booleandelete()Deletes the file, or the directory and its children.Returns the relative paths of all descendant files (excluding directories).descendants(FileFilter filter) Returns the relative paths of all descendant non-filtered files (excluding directories).booleanCompares the filename of the specified IO reference.booleanbooleanexists()Tests if the reference exists.file()Returns the file reference.booleanignore()Checks if the parent directory of this file can be ignored.Returns an input source.Returns an input stream.booleanTests if this is an absolute path.booleanisDir()Tests if this is a local directory instance, or if the path ends with a slash.booleanisHidden()Checks if a file is hidden.static booleanChecks if the specified string is a valid file reference.static booleanisValidName(String name) Checks if the specified string is a valid file name.longlength()Returns the file length.booleanmd()Recursively creates the directory if it does not exist yet.Returns a native file path representation.voidopen()Opens the file externally.Returns an output stream.parent()Returns the parent of this file or directory ornullif there is no parent directory.byte[]read()Returns the binary contents.static StringConverts a name filter (glob) to a regular expression.static StringConverts a file filter (glob) to a regular expression.booleanRenames a file to the specified path.Resolves two paths.Returns a stream source.longReturns the time stamp (modification date) of this file.booleantouch()Creates a new instance of this file.url()Creates a URL from the specified path.voidwrite(byte[] bytes) Writes the specified byte array.voidwrite(InputStream is) Writes the specified input.voidWrites the specified string as UTF8.
-
Field Details
-
NO_HIDDEN
Ignore files starting with a dot.
-
-
Constructor Details
-
IOFile
Constructor.- Parameters:
file- file reference
-
IOFile
Constructor.- Parameters:
path- file path
-
IOFile
Constructor.- Parameters:
dir- parent directory stringchild- child directory string
-
IOFile
Constructor.- Parameters:
dir- directory stringchild- child path string
-
-
Method Details
-
file
Returns the file reference.- Returns:
- file reference
-
touch
public boolean touch()Creates a new instance of this file.- Returns:
- success flag
-
read
Description copied from class:IOReturns the binary contents.- Specified by:
readin classIO- Returns:
- binary contents
- Throws:
IOException- I/O exception
-
exists
public boolean exists()Description copied from class:IOTests if the reference exists. Returnstruefor IO instances other thanIOFile. -
isDir
public boolean isDir()Description copied from class:IOTests if this is a local directory instance, or if the path ends with a slash. -
isAbsolute
public boolean isAbsolute()Description copied from class:IOTests if this is an absolute path.- Overrides:
isAbsolutein classIO- Returns:
- result of check
-
timeStamp
public long timeStamp()Description copied from class:IOReturns the time stamp (modification date) of this file. Returns the current time for IO instances other thanIOFile. -
length
public long length()Description copied from class:IOReturns the file length. -
inputSource
Description copied from class:IOReturns an input source.- Specified by:
inputSourcein classIO- Returns:
- input source
-
streamSource
Description copied from class:IOReturns a stream source.- Specified by:
streamSourcein classIO- Returns:
- stream source
-
inputStream
Description copied from class:IOReturns an input stream.- Specified by:
inputStreamin classIO- Returns:
- input stream
- Throws:
IOException- I/O exception
-
outputStream
Returns an output stream.- Returns:
- output stream
- Throws:
IOException- I/O exception
-
resolve
Resolves two paths.- Parameters:
path- file path (relative or absolute)- Returns:
- resulting path
-
md
public boolean md()Recursively creates the directory if it does not exist yet.- Returns:
trueif the directory exists or has been created
-
parent
Returns the parent of this file or directory ornullif there is no parent directory.- Returns:
- directory or
null
-
children
Returns the children of the path.- Returns:
- children
-
children
Returns the children of the path that match the specified regular expression.- Parameters:
regex- regular expression pattern- Returns:
- children
-
children
Returns the children of the path that match the specified filter.- Parameters:
filter- file filter- Returns:
- children
-
descendants
Returns the relative paths of all descendant files (excluding directories).- Returns:
- relative paths
-
descendants
Returns the relative paths of all descendant non-filtered files (excluding directories).- Parameters:
filter- file filter- Returns:
- relative paths
-
write
Writes the specified string as UTF8.- Parameters:
string- string- Throws:
IOException- I/O exception
-
write
Writes the specified byte array.- Parameters:
bytes- bytes- Throws:
IOException- I/O exception
-
write
Writes the specified input. The specified input stream is eventually closed.- Parameters:
is- input stream- Throws:
IOException- I/O exception
-
delete
public boolean delete()Deletes the file, or the directory and its children.- Returns:
trueif the file does not exist or has been deleted
-
rename
Renames a file to the specified path. The path must not exist yet.- Parameters:
target- target reference- Returns:
- success flag
-
copyTo
Copies a file to another target.- Parameters:
target- target- Throws:
IOException- I/O exception
-
eq
Description copied from class:IOCompares the filename of the specified IO reference. -
equals
-
url
Description copied from class:IOCreates a URL from the specified path. Returns the original path for IO instances other thanIOFile. -
open
Opens the file externally.- Throws:
IOException- I/O exception
-
normalize
Returns a native file path representation. If normalization fails, returns the original path.- Returns:
- path
-
isHidden
public boolean isHidden()Checks if a file is hidden.- Returns:
- result of check
-
ignore
public boolean ignore()Checks if the parent directory of this file can be ignored.- Returns:
- result of check
-
isValidName
Checks if the specified string is a valid file name.- Parameters:
name- file name- Returns:
- result of check
-
isValid
Checks if the specified string is a valid file reference.- Parameters:
path- path string- Returns:
- result of check
-
regex
Converts a name filter (glob) to a regular expression.- Parameters:
glob- filter- Returns:
- regular expression
-
regex
Converts a file filter (glob) to a regular expression. A filter may contain asterisks (*) and question marks (?); commas (,) are used to separate multiple filters.- Parameters:
glob- filtersubstring- accept substring in the result- Returns:
- regular expression
-