Spreadsheet Toolkit

corpus.fileIO
Class FileIO

java.lang.Object
  |
  +--corpus.fileIO.FileIO

public class FileIO
extends java.lang.Object

Performs basic File IO. Read from disk, save to disk...


Constructor Summary
FileIO()
           
 
Method Summary
static boolean argsContains(java.lang.String[] args, java.lang.String delim)
           
static byte[] arrayCombine(byte[] one, byte[] two, int twolength)
          Combines two arrays
static java.io.File browse(java.lang.String startdir, java.lang.String extension, java.lang.String description)
          Find a file using a FileChooser
static Directory browseDirs(java.lang.String startdir, java.lang.String title)
          Find a directory using a JFileChooser http://www.rgagnon.com/javadetails/java-0370.html
static Grid browseGrid()
           
static Grid browseGrid(java.lang.String startpath)
          Allows user to browse for grid files
static WorkBook browseWorkBookFromExcel()
           
static WorkBook browseWorkBookFromExcel(java.lang.String start_path)
          Allows the user to browse for a Excel files.
static java.lang.Object byteA_to_object_zip(byte[] buf)
           
static java.lang.Object byteA_to_object(byte[] buf)
           
static java.lang.String checkPath(java.lang.String path)
          Converts file paths to use local OS path.separator.
static java.util.Vector cleanUrlFile(java.lang.String inputfile)
          Remove any duplicates (done at load time) and sort.
static boolean exists(java.lang.String path, long size)
           
static java.lang.String[] getGoogleKeys()
          Returns keys to be used with the google api.
static java.lang.String[] getProxyAuthenticationData()
          Read the encoded ProxyAuthentication Data from files/pa.txt
Requires setMaster to be called first.
static java.util.Vector intersection(java.util.Vector v1, java.util.Vector v2)
          Takes two Vectors and returns the intersection (no duplicates).
static byte[] load(java.lang.String path)
          Return the file stored at path as a byte array.
static void main(java.lang.String[] args)
          The main program for the FileIO class
static byte[] object_to_byteA_zip(java.lang.Object o)
           
static byte[] object_to_byteA(java.lang.Object o)
           
static java.util.Vector openURLlist(java.lang.String inputfile)
           
static int optionDialog(javax.swing.JFrame frame, java.lang.Object[] options, java.lang.String title, java.lang.String message)
           
static boolean optionDialogTrueFalse(javax.swing.JFrame frame, java.lang.String title, java.lang.String message, java.lang.String falseLabel, java.lang.String trueLabel)
           boolean result = FileIO.optionDialogTrueFalse(null, "Dialog title", "Dialog Message", "Return False option","Return True option");
static java.lang.String parseArgs(java.lang.String[] args, java.lang.String delim)
           
static void setMaster(java.lang.String string)
          Set the master password to decode the Proxy Authentication Data
static void store(java.lang.String outputfile, byte[] outfile)
          Store a byte array version of the file on the harddisk.
static void store(java.lang.String outputfile, java.lang.String outfile)
          Store a String on the harddisk.
static void storeCellTree(java.lang.String outputfile, Cell c)
          Given an array of urls this will store them in a file.
static void storeURLArray(java.lang.String outputfile, java.lang.String[] urls)
           
static void storeURLArray(java.lang.String outputfile, java.lang.String[] urls, boolean append)
          Given an array of urls this will store them in a file.
static void storeXLS(java.lang.String outputfile, byte[] outfile, java.lang.String url, boolean retry)
          Store a byte array version of the file on the harddisk.
static java.util.Vector union(java.util.Vector v1, java.util.Vector v2)
          Takes two Vectors and returns the union (no duplicates).
static java.util.Vector unionDuplicates(java.util.Vector v1, java.util.Vector v2)
          Takes two Vectors and returns the union (with duplicates).
static void writeAnimatedGIF(java.awt.Image[] still_images, java.lang.String annotation, boolean looped, double frames_per_second, java.io.OutputStream out)
          Given an array of Java Image classes, create an animated gif image on disk.
static void writeAnimatedGif(java.lang.String[] filenames, java.lang.String annotation, boolean looped, double frames_per_second, java.lang.String outputfile)
          Create animated gif from a series of static gif files.
static void writeAnimatedGif(java.util.Vector still_images, java.lang.String annotation, boolean looped, double frames_per_second, java.lang.String outputfile)
          Same as writeAnimatedGIF but takes a vector rather than array.
static void writeAnimatedGifFrames(java.util.Vector still_images, java.lang.String annotation, boolean looped, double frames_per_second, java.lang.String outputfile)
          Saves each image to a seperate file with the frame number appended to the end.
static void writeNormalGif(java.awt.Image img, java.lang.String annotation, int transparent_index, boolean interlaced, java.io.OutputStream out)
          Given a Java Image class, create a gif image on disk.
static void writeNormalGIF(java.awt.Image img, java.lang.String annotation, int transparent_index, boolean interlaced, java.lang.String filename)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileIO

public FileIO()
Method Detail

main

public static void main(java.lang.String[] args)
The main program for the FileIO class

Parameters:
args - usage: java corpus.Fetcher inputfile outputfile

store

public static void store(java.lang.String outputfile,
                         byte[] outfile)
Store a byte array version of the file on the harddisk.

Parameters:
outputfile - File name for disk
outfile - The data to store

store

public static void store(java.lang.String outputfile,
                         java.lang.String outfile)
Store a String on the harddisk.

Parameters:
outputfile - File name for disk
outfile - The data to store

storeURLArray

public static void storeURLArray(java.lang.String outputfile,
                                 java.lang.String[] urls)

storeURLArray

public static void storeURLArray(java.lang.String outputfile,
                                 java.lang.String[] urls,
                                 boolean append)
Given an array of urls this will store them in a file.


openURLlist

public static java.util.Vector openURLlist(java.lang.String inputfile)

cleanUrlFile

public static java.util.Vector cleanUrlFile(java.lang.String inputfile)
Remove any duplicates (done at load time) and sort.


storeXLS

public static void storeXLS(java.lang.String outputfile,
                            byte[] outfile,
                            java.lang.String url,
                            boolean retry)
Store a byte array version of the file on the harddisk.

Parameters:
outputfile - File name for disk
outfile - The data to store
url - The location the file was downloaded from.

load

public static byte[] load(java.lang.String path)
Return the file stored at path as a byte array.

Parameters:
path - The location to load from
Returns:
The file as a byte[]

exists

public static boolean exists(java.lang.String path,
                             long size)

getGoogleKeys

public static java.lang.String[] getGoogleKeys()
Returns keys to be used with the google api.


storeCellTree

public static void storeCellTree(java.lang.String outputfile,
                                 Cell c)
Given an array of urls this will store them in a file.


arrayCombine

public static byte[] arrayCombine(byte[] one,
                                  byte[] two,
                                  int twolength)
Combines two arrays


object_to_byteA_zip

public static byte[] object_to_byteA_zip(java.lang.Object o)
See Also:
Zip

object_to_byteA

public static byte[] object_to_byteA(java.lang.Object o)

byteA_to_object_zip

public static java.lang.Object byteA_to_object_zip(byte[] buf)
Returns:
The uncompress data, null if a read error occured.
See Also:
Unzip

byteA_to_object

public static java.lang.Object byteA_to_object(byte[] buf)

union

public static java.util.Vector union(java.util.Vector v1,
                                     java.util.Vector v2)
Takes two Vectors and returns the union (no duplicates).


unionDuplicates

public static java.util.Vector unionDuplicates(java.util.Vector v1,
                                               java.util.Vector v2)
Takes two Vectors and returns the union (with duplicates).


intersection

public static java.util.Vector intersection(java.util.Vector v1,
                                            java.util.Vector v2)
Takes two Vectors and returns the intersection (no duplicates).


parseArgs

public static java.lang.String parseArgs(java.lang.String[] args,
                                         java.lang.String delim)
Returns:
the String following the delimiter in args if it exists, else null. The read delim and arg will be set to null if read correctly.

argsContains

public static boolean argsContains(java.lang.String[] args,
                                   java.lang.String delim)
Returns:
true is the delimiter is present in the args, else false.

optionDialog

public static int optionDialog(javax.swing.JFrame frame,
                               java.lang.Object[] options,
                               java.lang.String title,
                               java.lang.String message)
Returns:
the index of the selected option.

optionDialogTrueFalse

public static boolean optionDialogTrueFalse(javax.swing.JFrame frame,
                                            java.lang.String title,
                                            java.lang.String message,
                                            java.lang.String falseLabel,
                                            java.lang.String trueLabel)
boolean result = FileIO.optionDialogTrueFalse(null, "Dialog title", "Dialog Message", "Return False option","Return True option");


browseWorkBookFromExcel

public static WorkBook browseWorkBookFromExcel(java.lang.String start_path)
Allows the user to browse for a Excel files. When read will save to disk (done by Extractor class).

Returns:
The WorkBook file if read, else null.

browseWorkBookFromExcel

public static WorkBook browseWorkBookFromExcel()

browseGrid

public static Grid browseGrid()

browseGrid

public static Grid browseGrid(java.lang.String startpath)
Allows user to browse for grid files

See Also:
Grid

browse

public static java.io.File browse(java.lang.String startdir,
                                  java.lang.String extension,
                                  java.lang.String description)
Find a file using a FileChooser

Parameters:
startdir - The path to the directory to start browsing from.
description - A description to give the user of the file type.

browseDirs

public static Directory browseDirs(java.lang.String startdir,
                                   java.lang.String title)
Find a directory using a JFileChooser http://www.rgagnon.com/javadetails/java-0370.html

Parameters:
startdir - The path to the directory to start browsing from.
title - Titlebar label.

checkPath

public static java.lang.String checkPath(java.lang.String path)
Converts file paths to use local OS path.separator.


setMaster

public static void setMaster(java.lang.String string)
Set the master password to decode the Proxy Authentication Data


getProxyAuthenticationData

public static java.lang.String[] getProxyAuthenticationData()
Read the encoded ProxyAuthentication Data from files/pa.txt
Requires setMaster to be called first.


writeNormalGIF

public static void writeNormalGIF(java.awt.Image img,
                                  java.lang.String annotation,
                                  int transparent_index,
                                  boolean interlaced,
                                  java.lang.String filename)
                           throws java.io.IOException
java.io.IOException

writeNormalGif

public static void writeNormalGif(java.awt.Image img,
                                  java.lang.String annotation,
                                  int transparent_index,
                                  boolean interlaced,
                                  java.io.OutputStream out)
                           throws java.io.IOException
Given a Java Image class, create a gif image on disk.

java.io.IOException

writeAnimatedGifFrames

public static void writeAnimatedGifFrames(java.util.Vector still_images,
                                          java.lang.String annotation,
                                          boolean looped,
                                          double frames_per_second,
                                          java.lang.String outputfile)
Saves each image to a seperate file with the frame number appended to the end.


writeAnimatedGif

public static void writeAnimatedGif(java.lang.String[] filenames,
                                    java.lang.String annotation,
                                    boolean looped,
                                    double frames_per_second,
                                    java.lang.String outputfile)
Create animated gif from a series of static gif files.


writeAnimatedGif

public static void writeAnimatedGif(java.util.Vector still_images,
                                    java.lang.String annotation,
                                    boolean looped,
                                    double frames_per_second,
                                    java.lang.String outputfile)
Same as writeAnimatedGIF but takes a vector rather than array.


writeAnimatedGIF

public static void writeAnimatedGIF(java.awt.Image[] still_images,
                                    java.lang.String annotation,
                                    boolean looped,
                                    double frames_per_second,
                                    java.io.OutputStream out)
                             throws java.io.IOException
Given an array of Java Image classes, create an animated gif image on disk.

java.io.IOException

Spreadsheet Toolkit

Project Home Page