The goal is simple; given a input file, read the file and then rewrite the output based on that file. I am using this particular code for log file analysis.
Python pseudo code:
f = open(filename)
fw = open(filename, 'w')
data = f.read()
for line in data:
The java version is just that, but I wanted to do the iteration around reading a line through callbacks (anonymous inner subclasses). I designed the following loadFile routine to use an implementation of some ReaderWriter class because you certainly want to control how you iterate through each line of the document and only to focus on that particular task as opposed to the inner details of how the file gets opened or closed. For example:
FileUtil.loadFile(filename, (new HtmlFileUtilReaderWriter()
public void read(BufferedReader bufInput, List resultList) :
while ((feed = bufInput.readLine()) != null
That is basically it, I know it is simple but it is pretty useful idiom. You can download the full source from my googlecode repository. In the future, I hope to create a similar set of libraries in Haskell and compare and contrast between the two languages.