Hi, I wanna do an applet that write text information in a log file, but when the file don't exists, I need generate an exception because is needed write some data in the top of file.
string patch = "c:/logs/logs.log";
FileWriter file;
PrintWriter output;
try
{
file = new FileWriter(patch, true); //bool tells to append
file.write("\n");
println("exist");
file.close();
}
catch(Exception e)
{
output = createWriter(caminho);
output.close();
println("except");
try
{
file = new FileWriter(caminho, true); //bool tells to append
file.write("Some data");
file.close();
}
catch(Exception e2)
{
e.printStackTrace();
println();
e2.printStackTrace();
}
}
This only works when the patch "c:/logs" don't exists, and I need this works when the patch exists, but not the file "logs.log"