|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.util.FileLocator
public class FileLocator
Constructor Summary | |
---|---|
FileLocator(Global glob)
Constructor. |
Method Summary | |
---|---|
static void |
appendToFile(java.lang.String outName,
java.lang.String str)
Append data from into a file. |
static java.lang.String |
concatPath(java.lang.String path,
java.lang.String name)
Concatenate a filename to a path (DOS and UNIX, checks for separator). |
java.lang.String[] |
createXmlBlasterSearchPath()
|
static boolean |
deleteDir(java.io.File dir)
Deletes all files and subdirectories under dir. |
static void |
deleteFile(java.lang.String parent,
java.lang.String fileName)
|
static java.lang.String |
extensionToMime(java.lang.String extension,
java.lang.String defaultVal)
Convert some file extensions to MIME types. |
java.lang.String |
findFile(java.lang.String[] path,
java.lang.String filename)
Searches in the given path for the specified filename. |
java.lang.String |
findFile(java.lang.String path,
java.lang.String filename)
finds the file in the given path. |
java.lang.String |
findFile(java.lang.String path,
java.lang.String separator,
java.lang.String filename)
finds the file in the given path. |
java.net.URL |
findFileInXmlBlasterSearchPath(java.lang.String propertyName,
java.lang.String filename)
tries to find a file according to the xmlBlaster Strategy. |
static java.lang.String |
getBody(java.lang.String fileName)
Strip the path and the file name extension. |
static java.lang.String |
getExtension(java.lang.String fileName)
Return the file name extension. |
static void |
main(java.lang.String[] args)
java org.xmlBlaster.util.FileLocator -pluginsFile http://www.xmlblaster.org/empty.html |
java.lang.String[] |
parsePath(java.lang.String pathAsString,
java.lang.String separator)
Parses the given Path into an array of String. |
java.lang.String |
read(java.net.URL url)
|
static java.lang.String |
readAsciiFile(java.lang.String fileName)
Read a file into String . |
static java.lang.String |
readAsciiFile(java.lang.String parent,
java.lang.String child)
Read a file into String . |
static byte[] |
readFile(java.io.File f)
|
static byte[] |
readFile(java.lang.String fileName)
Read a file into byte[] . |
static byte[] |
readFile(java.lang.String parent,
java.lang.String fileName)
Read a file into byte[] . |
static void |
writeFile(java.lang.String name,
byte[] arr)
Write data from StringBuffer into a file. |
static void |
writeFile(java.lang.String name,
java.lang.String str)
Write data from StringBuffer into a file. |
static void |
writeFile(java.lang.String parent,
java.lang.String child,
byte[] arr)
Write data from byte[] into a file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileLocator(Global glob)
Method Detail |
---|
public final java.lang.String findFile(java.lang.String[] path, java.lang.String filename) throws XmlBlasterException
path
- the path on which to search for the given file.filename
- the name of the file to search. NOTE: if it is an absolute filename, then the path
is ignored and a warning is written to the log.
XmlBlasterException
- with error code resource.configuration if either the file has been found
but it can not be read, or if it is a directory. Note that if there are several files in the
given path and the first one found is either read protected or is a directory, then the second
is taken and no exception is thrown.public final java.lang.String[] parsePath(java.lang.String pathAsString, java.lang.String separator)
public final java.lang.String findFile(java.lang.String path, java.lang.String separator, java.lang.String filename) throws XmlBlasterException
XmlBlasterException
public final java.lang.String findFile(java.lang.String path, java.lang.String filename) throws XmlBlasterException
XmlBlasterException
public final java.lang.String[] createXmlBlasterSearchPath()
public java.lang.String read(java.net.URL url) throws XmlBlasterException
XmlBlasterException
public final java.net.URL findFileInXmlBlasterSearchPath(java.lang.String propertyName, java.lang.String filename)
filename
-
public static final byte[] readFile(java.lang.String parent, java.lang.String fileName) throws XmlBlasterException
byte[]
.
byte[] data=FileLocator.readFile("/tmp", "hello.txt");
parent
- Path to the file, can be nullfileName
- Name of file
XmlBlasterException
- if the file is not readable or any error occurred while reading the file.public static final byte[] readFile(java.io.File f) throws XmlBlasterException
XmlBlasterException
public static final void writeFile(java.lang.String parent, java.lang.String child, byte[] arr) throws XmlBlasterException
byte[]
into a file.
parent
- the path, can be nullchild
- the namearr
- data
XmlBlasterException
public static final void writeFile(java.lang.String name, java.lang.String str) throws XmlBlasterException
StringBuffer
into a file.
outName
- name of file including pathstr
- data
XmlBlasterException
public static final void writeFile(java.lang.String name, byte[] arr) throws XmlBlasterException
StringBuffer
into a file.
outName
- name of file including pathstr
- some binary data
XmlBlasterException
public static final void appendToFile(java.lang.String outName, java.lang.String str) throws XmlBlasterException
outName
- name of file including pathstr
- Text
XmlBlasterException
public static final java.lang.String readAsciiFile(java.lang.String fileName) throws XmlBlasterException
String
.
fileName
- Complete name of file
XmlBlasterException
public static final java.lang.String readAsciiFile(java.lang.String parent, java.lang.String child) throws XmlBlasterException
String
.
String data=FileUtil.readAsciiFile("/tmp/hello");
parent
- Path to the filefileName
- name of file
XmlBlasterException
public static final byte[] readFile(java.lang.String fileName) throws XmlBlasterException
byte[]
.
fileName
- Complete name of file
JUtilsException
- if the file is not readable or any error occured while reading the file.
XmlBlasterException
public static final void deleteFile(java.lang.String parent, java.lang.String fileName)
public static java.lang.String concatPath(java.lang.String path, java.lang.String name)
path
- for example "/tmp"name
- for example "hello.txt"
public static java.lang.String getExtension(java.lang.String fileName)
fileName
- for example "/tmp/hello.txt"
public static java.lang.String getBody(java.lang.String fileName)
fileName
- for example "/tmp/hello.txt"
public static boolean deleteDir(java.io.File dir)
public static java.lang.String extensionToMime(java.lang.String extension, java.lang.String defaultVal)
extension
- for example "xml"defaultVal
- for example "text/plain"
public static void main(java.lang.String[] args)
args
-
|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |