BASEXSUFFIX, BLOCKSIZE, BXSSUFFIX, CSVSUFFIX, ENTRIES, FILEPREF, GZSUFFIX, HTMLSUFFIXES, JARSUFFIX, JSONSUFFIX, JSSUFFIX, LOGSUFFIX, MAXATTS, NODEPOWER, NODESIZE, OFFCOMP, OFFNUM, RAW, TARGZSUFFIX, TARSUFFIX, TGZSUFFIX, TXTSUFFIXES, XARSUFFIX, XMLSUFFIX, XMLSUFFIXES, XQMSUFFIX, XQSUFFIX, XQSUFFIXES, XSLSUFFIXES, ZIPSUFFIX, ZIPSUFFIXES
Constructor and Description |
---|
IOFile(File file)
Constructor.
|
IOFile(IOFile dir,
String name)
Constructor.
|
IOFile(String path)
Constructor.
|
IOFile(String dir,
String name)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
IOFile[] |
children()
Returns the children of the path.
|
IOFile[] |
children(String regex)
Returns the children of the path that match the specified regular
expression.
|
void |
copyTo(IOFile target)
Copies a file to another target.
|
boolean |
delete()
Deletes the file or directory.
|
StringList |
descendants()
Returns the relative paths of all descendant files.
|
String |
dir()
Returns the directory path.
|
boolean |
eq(IO io)
Compares the filename of the specified IO reference.
|
boolean |
exists()
Tests if the reference exists.
|
File |
file()
Returns the file reference.
|
InputSource |
inputSource()
Returns an input source.
|
InputStream |
inputStream()
Returns an input stream.
|
boolean |
isDir()
Tests if this is a directory instance.
|
static boolean |
isValid(String path)
Checks if the specified string is a valid file reference.
|
static boolean |
isValidName(String name)
Checks if the specified sting is a valid file name.
|
long |
length()
Returns the file length.
|
boolean |
md()
Recursively creates the directory if it does not exist yet.
|
IO |
merge(String path)
Merges two paths.
|
IOFile |
normalize()
Returns a native file path representation.
|
void |
open()
Opens the file externally.
|
IOFile |
parent()
Returns the parent of this file or directory or
null if there is no parent directory. |
byte[] |
read()
Returns the binary contents.
|
static String |
regex(String glob)
Converts a name filter (glob) to a regular expression.
|
static String |
regex(String glob,
boolean sub)
Converts a file filter (glob) to a regular expression.
|
String |
relative(IOFile path)
Returns a path to the specified path.
|
boolean |
rename(IOFile target)
Renames a file to the specified path.
|
IOFile |
resolve(String path)
Resolves two paths.
|
StreamSource |
streamSource()
Returns a stream source.
|
long |
timeStamp()
Returns the time stamp (modification date) of this file.
|
boolean |
touch()
Creates a new instance of this file.
|
String |
url()
Creates a URL from the specified path.
|
void |
write(byte[] bytes)
Writes the specified byte array.
|
void |
write(InputStream in)
Writes the specified input.
|
public IOFile(String path)
path
- file pathpublic IOFile(File file)
file
- file referencepublic IOFile(String dir, String name)
dir
- directoryname
- file namepublic File file()
public boolean touch()
public byte[] read() throws IOException
IO
read
in class IO
IOException
- I/O exceptionpublic boolean exists()
IO
true
for IO instances other than IOFile
.public boolean isDir()
IO
false
for IO instances other than IOFile
.public long timeStamp()
IO
IOFile
.public long length()
IO
public InputSource inputSource()
IO
inputSource
in class IO
public StreamSource streamSource()
IO
streamSource
in class IO
public InputStream inputStream() throws IOException
IO
inputStream
in class IO
IOException
- I/O exceptionpublic IOFile resolve(String path)
path
- file path (relative or absolute)public boolean md()
true
if the directory exists or has been created.public IOFile parent()
null
if there is no parent directory.null
public IOFile[] children()
public IOFile[] children(String regex)
regex
- regular expression patternpublic StringList descendants()
public void write(byte[] bytes) throws IOException
bytes
- bytesIOException
- I/O exceptionpublic void write(InputStream in) throws IOException
in
- input streamIOException
- I/O exceptionpublic boolean delete()
true
if the file does not exist or has been deleted.public boolean rename(IOFile target)
target
- target referencepublic void copyTo(IOFile target) throws IOException
target
- targetIOException
- I/O exceptionpublic boolean eq(IO io)
IO
public String url()
IO
IOFile
.public void open() throws IOException
IOException
- I/O exceptionpublic IOFile normalize()
public String relative(IOFile path)
path
- relative pathpublic static boolean isValidName(String name)
name
- file namepublic static boolean isValid(String path)
path
- path stringpublic static String regex(String glob)
glob
- filterpublic static String regex(String glob, boolean sub)
glob
- filtersub
- accept substring in the resultCopyright © 2005–2015 BaseX Team. All rights reserved.