When I compile the below code, it shows error “cannot find symbol variable out”
But if i comment the code in the finally block, I am able to compile successfully.
Please advise.
public static int writeFile (String p_file_path, String p_data) throws Exception
{
try {
FileWriter outFile = new FileWriter(p_file_path,true);
PrintWriter out = new PrintWriter(outFile);
out.println(p_data);
} catch (Exception e) {
} finally {
out.close();
}
return SUCCESS;
}
You need to define “out” outside try-block if you want to reference it in the finally block, something like