|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--FileIO
This file I/O class includes methods to do file I/O to a local disk or URL. The disk (standalone file:// mode) or through a URL (standalone or applet http://) connects to a Web server. If you are doing a URL I/O is used, then it uses JavaCGIbridge to read files. If you are using password protection or writing a file to a URL, then it needs a cooperating CGI process running the the target Web server.
This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The MAExplorer Mozilla and Legal files are available on http://maexplorer.sourceforge.net/.
Field Summary | |
private char[] |
logDataBuf
standalone log file data buff |
private int |
logDataBufSize
size of standalone log file data buff |
private java.io.File |
logFile
standalone log file descriptor |
private java.lang.String |
logFileName
standalone log file name |
(package private) java.io.FileWriter |
logFileWriter
standalone log file writer |
private MAExplorer |
mae
link to global MAExplorer instance |
Constructor Summary | |
(package private) |
FileIO(MAExplorer mae)
FileIO() - constructor to create fio instance and to close the log file. |
Method Summary | |
private java.lang.String |
cacheRead(java.lang.String fullFilePath)
cacheRead() - read data file from Cache file it it exists. |
private boolean |
cacheWrite(java.lang.String fullFilePath,
java.lang.String data)
cacheWrite() - Write string into file in local cache. |
(package private) void |
closeLogFile()
closeLogFile() - close log file if it is open, but always reset the log state |
boolean |
copyFile(java.lang.String srcName,
java.lang.String dstName,
java.lang.String optUpdateMsg,
int optEstInputFileLth)
copyFile() - binary copy of one file or URL to a local file |
private java.lang.String |
createCacheFileName(java.lang.String fullFilePath)
createCacheFileName() - create cache file name. |
boolean |
deleteLocalFile(java.lang.String fileName)
deleteLocalFile() - delete local file. |
boolean |
deleteRecursive(java.io.File dirNameToDelete)
|
boolean |
extractZipFiles(java.lang.String zipFileName,
java.lang.String rootPath)
extractZipFiles() - extract files from zip file. |
(package private) void |
logMsg(java.lang.String msg)
logMsg() - write msg to opened log file if stand-alone else print to Java console. |
(package private) void |
logMsg(java.lang.String msg,
java.lang.String logFileName,
boolean newFileFlag,
boolean appendFlag)
logMsg() - write msg to log file. |
(package private) void |
logMsgln(java.lang.String msg)
logMsgln() - write msg+"\n" to opened log file if stand-alone else if applet, just do System.out.println() call to java console. |
byte[] |
readBytesFromURL(java.lang.String srcName,
java.lang.String optUpdateMsg)
readBytesFromURL() - read binary data from URL |
(package private) java.lang.String |
readData(java.lang.String fileName,
java.lang.String msg)
readData() - read data from URL or local file depending on prefix. |
(package private) java.lang.String |
readFileFromDisk(java.lang.String fileName)
readFileFromDisk() - read file from disk and return entire file as String |
(package private) java.lang.String |
readFileFromUrl(java.lang.String URLaddress,
boolean sendAuthReqFlag)
readFileFromUrl() - read data from http:// URL, using JavaCGIBridge. |
(package private) java.lang.String |
readZipFileFromDisk(java.lang.String fileName,
java.lang.String entryName)
readZipFileFromDisk() - [TODO] read Zip file from disk and return it as a String. |
(package private) boolean |
writeData(java.lang.String fileName,
java.lang.String msg,
java.lang.String data)
writeData() - write data to a URL or local file depending on file name prefix. |
(package private) boolean |
writeFileFromUrl(java.lang.String URLaddress,
java.lang.String fileName,
java.lang.String data)
writeFileFromUrl() - write string data to http URL, using JavaCGIBridge. |
(package private) boolean |
writeFileToDisk(java.lang.String fileName,
java.lang.String data)
writeFileToDisk() - write string data to a local disk file. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private MAExplorer mae
private java.lang.String logFileName
private java.io.File logFile
java.io.FileWriter logFileWriter
private char[] logDataBuf
private int logDataBufSize
Constructor Detail |
FileIO(MAExplorer mae)
mae
- is instance of MAExplorercloseLogFile()
Method Detail |
java.lang.String readData(java.lang.String fileName, java.lang.String msg)
fileName
- is the full path filename to read the data. If it starts with
"http://" then it should be a URL.msg
- to display while reading the fileUtil.showMsg(java.lang.String)
,
cacheRead(java.lang.String)
,
cacheWrite(java.lang.String, java.lang.String)
,
readFileFromDisk(java.lang.String)
,
readFileFromUrl(java.lang.String, boolean)
boolean writeData(java.lang.String fileName, java.lang.String msg, java.lang.String data)
fileName
- is the full path filename to write the datamsg
- to display while writing the filedata
- is the string to write to the file.Util.showMsg(java.lang.String)
,
writeFileToDisk(java.lang.String, java.lang.String)
,
writeFileFromUrl(java.lang.String, java.lang.String, java.lang.String)
java.lang.String readFileFromDisk(java.lang.String fileName)
fileName
- is the full path filename to read the datalogMsgln(java.lang.String)
,
readZipFileFromDisk(java.lang.String, java.lang.String)
java.lang.String readZipFileFromDisk(java.lang.String fileName, java.lang.String entryName)
fileName
- is the full path zip filename to read the dataentryName
- is the particular entry to read from the zip filelogMsgln(java.lang.String)
public boolean extractZipFiles(java.lang.String zipFileName, java.lang.String rootPath)
zipfileName
- Name of zip file including full pathrootPath
- Directory to extract the zip filejava.lang.String readFileFromUrl(java.lang.String URLaddress, boolean sendAuthReqFlag)
URLaddress
- is the full URLaddress to read the datasendAuthReqFlag
- is the authorization required (optional)JavaCGIBridge
,
JavaCGIBridge.getRawCGIData(java.net.URL)
,
logMsgln(java.lang.String)
boolean writeFileToDisk(java.lang.String fileName, java.lang.String data)
fileName
- is the full path filename to write the datadata
- is the string to write to the file.logMsgln(java.lang.String)
boolean writeFileFromUrl(java.lang.String URLaddress, java.lang.String fileName, java.lang.String data)
URLaddress
- is the full CGI URL to write the datafileName
- is the filename on the serverdata
- is the string to write to the file.JavaCGIBridge
,
JavaCGIBridge.setThreadJavaCGIBridgeTimeOut(int)
,
JavaCGIBridge.addFormValue(java.util.Hashtable, java.lang.String, java.lang.String)
,
JavaCGIBridge.getRawCGIData(java.net.URL)
,
logMsgln(java.lang.String)
private java.lang.String createCacheFileName(java.lang.String fullFilePath)
fullFilePath
- is the full path filename to read the dataprivate java.lang.String cacheRead(java.lang.String fullFilePath)
fullFilePath
- is the full path filename to read the datacreateCacheFileName(java.lang.String)
,
readFileFromDisk(java.lang.String)
private boolean cacheWrite(java.lang.String fullFilePath, java.lang.String data)
fullFilePath
- is the full path filename to write the datadata
- is the data to write to the filecreateCacheFileName(java.lang.String)
,
writeFileToDisk(java.lang.String, java.lang.String)
void closeLogFile()
void logMsg(java.lang.String msg)
void logMsgln(java.lang.String msg)
msg
- to write to log filevoid logMsg(java.lang.String msg, java.lang.String logFileName, boolean newFileFlag, boolean appendFlag)
msg
- to write, add \n if want it in the filelogFileName
- is name of log filenewFileFlag
- to force new fileappendFlag
- if want to append, else new filepublic boolean copyFile(java.lang.String srcName, java.lang.String dstName, java.lang.String optUpdateMsg, int optEstInputFileLth)
srcName
- is either a full path local file name or
a http:// prefixed URL string of the source file.dstName
- is the full path of the local destination file nameoptUpdateMsg
- (opt) will display message in showMsg() and
increasing ... in showMsg2(). One '.' for every 10K bytes read.
This only is used when reading a URL. Set to null if not used.optEstInputFileLth
- is the estimate size of the in;ut file if known
else 0. Used in progress bar.public byte[] readBytesFromURL(java.lang.String srcName, java.lang.String optUpdateMsg)
srcName
- is either a full path local file name or
a http:// prefixed URL string of the source file.optUpdateMsg
- (opt) will display message in showMsg() and
increasing ... in showMsg2(). One '.' for every 10K bytes read.
This only is used when reading a URL. Set to null if not used.public boolean deleteLocalFile(java.lang.String fileName)
fileName
- to be deleted on the local file system.public boolean deleteRecursive(java.io.File dirNameToDelete)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |