sem.util
Class FileReader

java.lang.Object
  extended by sem.util.FileReader

public class FileReader
extends java.lang.Object

Class for simplifying file reading. Given an input file, it will read it line by line. Given a directory, it will iterate through all the lines in all the files in that directory.


Constructor Summary
FileReader(java.lang.String inputPath)
          Constructs a new FileReader.
FileReader(java.lang.String inputPath, java.lang.String fileAddendum)
          Constructs a new FileReader.
 
Method Summary
 void close()
          Close the FileReader.
 boolean hasNext()
          Check whether the reader has any lines left.
static java.util.ArrayList<java.io.File> listFileRec(java.io.File file)
          Recursively find all files that are contained in that directory.
static void main(java.lang.String[] args)
          Example use case.
 java.lang.String next()
          Get the next line.
 void reset()
          Reset the FileReader.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileReader

public FileReader(java.lang.String inputPath)
Constructs a new FileReader. Takes as input the path to a file or a directory.

Parameters:
inputPath - Input path.

FileReader

public FileReader(java.lang.String inputPath,
                  java.lang.String fileAddendum)
Constructs a new FileReader. Takes as input the path to a file or a directory. Also allows for specification of a string added to the end of each file. This can be useful if we want to separate data in different files by a newline, for example.

Parameters:
inputPath - Input path.
fileAddendum - String to be appended at the end of each file.
Method Detail

listFileRec

public static java.util.ArrayList<java.io.File> listFileRec(java.io.File file)
Recursively find all files that are contained in that directory. If given a file as input, it will return only that file.

Parameters:
file - Main file.
Returns:
ArrayList of files.

reset

public void reset()
Reset the FileReader.


close

public void close()
Close the FileReader.


next

public java.lang.String next()
Get the next line.


hasNext

public boolean hasNext()
Check whether the reader has any lines left.


main

public static void main(java.lang.String[] args)
Example use case.

Parameters:
args -