[code=Java]package tests;
import java.io.*;
public class Tests
{
private static final String LOG_SEP = ";";
private PrintWriter protokoll;
public static void main(String[] args) throws Exception
{
Tests test = new Tests();
test.initialise();
test.writeLog(test.getLoggingHeader());
test.writeLog("Max" + LOG_SEP + "Mustermann" + LOG_SEP + "01.01.2000");
test.end();
}
private void initialise() throws FileNotFoundException
{
// Protokolldatei anlegen
String fileURLProtokoll = "C:\\Daten\\WasAuchImmer.CSV";
protokoll = new PrintWriter(fileURLProtokoll);
}
private void writeLog(String text)
{
protokoll.println(text);
}
private String getLoggingHeader()
{
return "Name" + LOG_SEP + "Vorname" + LOG_SEP + "Geburtsdatum";
}
private void end()
{
if(protokoll != null)
{
protokoll.close();
}
}
}
[/code]
Du solltest die Exceptions, falls du es so benutzen willst, allerdings besser try-catchen und dass protokoll.close() in den finally-Block setzen.
Gruß
Luk