public class FileUtils
extends java.lang.Object
Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
downloadFile(java.lang.String urlString,
java.lang.String fileString)
read a remote file into a file.
|
static java.lang.String |
getInputFileName(java.lang.String currentDirectoryPath)
Create a file dialog and return the full name of the file selected.
|
static java.lang.String |
getInputFileName(java.lang.String currentDirectoryPath,
java.lang.String dialogTitle,
javax.swing.filechooser.FileFilter filter)
Create a file dialog and return the full name of the file selected.
|
static java.lang.String |
getOutputFileName(java.lang.String titleString,
java.lang.String currentDirectoryPath,
javax.swing.filechooser.FileNameExtensionFilter filter)
Gets the output file name.
|
static void |
main(java.lang.String[] args)
The main method.
|
static java.io.BufferedReader |
openFile(java.lang.String filename)
Open a file based on the filename and return a BufferedReader pointing at the
head of the file.
|
private static boolean |
printStatus(boolean status,
java.lang.String str)
print str if status is false?.
|
static java.io.BufferedReader |
readfileDialog(java.lang.String currentDirectoryPath)
Launch a file browsing dialog and return a BufferedReader pointing at the
head of the selected file.
|
static org.dom4j.Document |
readXML(java.lang.String fileStr)
read a XML file.
|
static java.lang.String |
testRead(java.io.BufferedReader fileReader)
read data from file and returns a string containing the contents.
|
static boolean |
unzipFile(java.lang.String fileName,
java.lang.String dirStr)
unzip a file to the directory dirStr.
|
static void |
writeXML(java.lang.String fileName,
org.dom4j.Document document)
write XML to a file.
|
public static java.lang.String getInputFileName(java.lang.String currentDirectoryPath)
currentDirectoryPath
- the current directory pathpublic static java.lang.String getOutputFileName(java.lang.String titleString, java.lang.String currentDirectoryPath, javax.swing.filechooser.FileNameExtensionFilter filter)
titleString
- the title stringcurrentDirectoryPath
- the current directory pathfilter
- the filter (i.e. .xls)public static java.lang.String getInputFileName(java.lang.String currentDirectoryPath, java.lang.String dialogTitle, javax.swing.filechooser.FileFilter filter)
currentDirectoryPath
- the current directory pathdialogTitle
- the dialog titlefilter
- the filter (i.e. .xls)public static java.io.BufferedReader openFile(java.lang.String filename) throws java.io.FileNotFoundException
filename
- the filenamejava.io.FileNotFoundException
public static java.io.BufferedReader readfileDialog(java.lang.String currentDirectoryPath) throws java.io.FileNotFoundException
currentDirectoryPath
- the current directory pathjava.io.FileNotFoundException
public static org.dom4j.Document readXML(java.lang.String fileStr) throws org.dom4j.DocumentException
fileStr
- the XML string to readorg.dom4j.DocumentException
public static void writeXML(java.lang.String fileName, org.dom4j.Document document) throws java.io.IOException
fileName
- the file namedocument
- the dom4j Document to write outjava.io.IOException
- Signals that an I/O exception has occurred.public static java.lang.String testRead(java.io.BufferedReader fileReader)
fileReader
- the BufferedReader pointing to the filepublic static boolean downloadFile(java.lang.String urlString, java.lang.String fileString)
urlString
- the url stringfileString
- the file string to save to.private static boolean printStatus(boolean status, java.lang.String str)
status
- the statusstr
- the strpublic static boolean unzipFile(java.lang.String fileName, java.lang.String dirStr)
fileName
- the zipped file namedirStr
- the name of the destination directorypublic static void main(java.lang.String[] args)
args
- the arguments