Class FileIO

java.lang.Object
  extended by FileIO

public class FileIO
extends java.lang.Object

Class FileIO is used to read file I/O from local disk or URL CGI 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 Flicker Mozilla and Legal files are available on http://open2dprot.sourceforge.net/Flicker

Version:
$Date$ $Revision$
Author:
P. Lemkin (LECB/NCI), G. Thornwall (SAIC), Frederick, MD
See Also:
Flicker Home

This work was derived from MAExplorer under the Mozilla 1.1 Open Source Public License by Peter Lemkin of the National Cancer Institute, an agency of the United States Government subject to the limitations noted in the accompanying LEGAL file. See licence info on http://maexplorer.sourceforge.org/


Field Summary
private  Flicker flk
          instance of Flicker
private  Util util
          instance of Util
 
Constructor Summary
FileIO(Flicker flk)
          FileIO() - constructor
 
Method Summary
 java.lang.String[] getFilesInDir(java.lang.String dir, java.lang.String ext)
          getFilesInDir() - get list of files in directory the specified file extension
 java.lang.String[] getFilesWithLegalExtnInDir(java.lang.String dir, java.lang.String[] legalExtList)
          getFilesWithLegalExtnInDir() - get list of files in directory with one of the specified file extensions
 java.lang.String readData(java.lang.String fileName, java.lang.String msg)
          readData() - read data from URL or file depending on prefix.
 java.lang.String readData(java.lang.String fileName, java.lang.String msg, boolean usePopupAlertsFlag)
          readData() - read data from URL or file depending on prefix.
 java.lang.String readFileFromDisk(java.lang.String fileName)
          readFileFromDisk() - Will read file from disk & returns as String Allow popup error messages.
 java.lang.String readFileFromDisk(java.lang.String fileName, boolean usePopupAlertsFlag)
          readFileFromDisk() - Will read file from disk & returns as String
 java.lang.String readFileFromUrl(java.lang.String URLaddress)
          readFileFromUrl() - read data from http URL, using JavaCGIBridge If the code has "\r\n", then map them to "\n".
(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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flk

private Flicker flk
instance of Flicker


util

private Util util
instance of Util

Constructor Detail

FileIO

FileIO(Flicker flk)
FileIO() - constructor

Parameters:
flk - is instance of Flicker
Method Detail

readData

public java.lang.String readData(java.lang.String fileName,
                                 java.lang.String msg)
readData() - read data from URL or file depending on prefix. return null if fail.

Parameters:
fileName - to read
msg - to display while reading
Returns:
null if failed.

readData

public java.lang.String readData(java.lang.String fileName,
                                 java.lang.String msg,
                                 boolean usePopupAlertsFlag)
readData() - read data from URL or file depending on prefix. return null if fail.

Parameters:
fileName - to read
msg - to display while reading
usePopupAlertsFlag - if allow popup error messages
Returns:
null if failed.

readFileFromDisk

public java.lang.String readFileFromDisk(java.lang.String fileName)
readFileFromDisk() - Will read file from disk & returns as String Allow popup error messages.

Parameters:
fileName - to read
Returns:
null if failed.

readFileFromDisk

public java.lang.String readFileFromDisk(java.lang.String fileName,
                                         boolean usePopupAlertsFlag)
readFileFromDisk() - Will read file from disk & returns as String

Parameters:
fileName - to read
usePopupAlertsFlag - if allow popup error messages
Returns:
null if failed.

readFileFromUrl

public java.lang.String readFileFromUrl(java.lang.String URLaddress)
readFileFromUrl() - read data from http URL, using JavaCGIBridge If the code has "\r\n", then map them to "\n". If the code has "\r" without "\n", then map them to "\n"

Parameters:
URLaddress - to read web page as string from server

writeFileToDisk

boolean writeFileToDisk(java.lang.String fileName,
                        java.lang.String data)
writeFileToDisk() - write string data to a local disk file.

Parameters:
fileName - is the full path filename to write the data
data - is the string to write to the file.
Returns:
string data for entire file if succeed, else null if fail.

getFilesWithLegalExtnInDir

public java.lang.String[] getFilesWithLegalExtnInDir(java.lang.String dir,
                                                     java.lang.String[] legalExtList)
getFilesWithLegalExtnInDir() - get list of files in directory with one of the specified file extensions

Parameters:
dir - directory to read
legalExtList - is the file extensions list (e.g. {".tif", ".jpg", ...}) to match if not null, else accept all files
Returns:
list of files

getFilesInDir

public java.lang.String[] getFilesInDir(java.lang.String dir,
                                        java.lang.String ext)
getFilesInDir() - get list of files in directory the specified file extension

Parameters:
dir - directory to read
ext - is the file extension (e.g. ".tif") to match if not null, else accept all files
Returns:
list of files