package edu.msoe.smv.raspi;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;

/**
 * TODO
 *
 * @author matt
 */
public class DataLogger {

	/**
	 * The file to log to
	 */
	private File logFile;
	/**
	 * The PrintWriter used for printing
	 */
	private PrintWriter writer;

	public DataLogger(File file) throws FileNotFoundException {
		if (file == null) {
			throw new IllegalArgumentException("file cannot be null");
		} else if (!file.canWrite() || !file.setWritable(true)) {
			throw new FileWritableException("log file could not be set writable");
		}

		this.logFile = file;
		this.writer = new PrintWriter(this.logFile);
	}

	/**
	 * Prints a DataNode's CSV to {@link #logFile}
	 *
	 * @param dataNode the DataNode to print
	 */
	public void log(DataNode dataNode) {
		writer.println(dataNode.toCSV());
		writer.flush();
	}

}

@@ -100,33 +100,104 @@
 .io.
-PrintWriter;%0A%0A/**%0A * TODO
+FileOutputStream;%0Aimport java.io.PrintWriter;%0A%0A/**%0A * Logs %7B@link DataNode DataNodes%7D to a file.
 %0A *%0A
@@ -242,17 +242,16 @@
 ogger %7B%0A
-%0A
 %09/**%0A%09 *
@@ -376,16 +376,225 @@
 riter;%0A%0A
+%09/**%0A%09 * Constructs a new DataLogger that logs to %3Ctt%3Efile%3C/tt%3E%0A%09 *%0A%09 * @param file the file to log to%0A%09 * @throws FileNotFoundException%0A%09 * @throws FileWritableException if %3Ctt%3Efile%3C/tt%3E is not writable%0A%09 */%0A
 %09public 
@@ -737,14 +737,11 @@
 %0A%09%09%7D
- else 
+%0A%09%09
 if (
@@ -921,28 +921,51 @@
 tWriter(
-this.logFile
+new FileOutputStream(logFile, true)
 );%0A%09%7D%0A%0A%09

Complete DataLogger