Domanda

I am making a class to handle Errors, called ErrorHandler Please correct me if this is not the best practice.

However, considering just about every method is going to use a BufferedWriter, should I simply initialize it as a field?

private BufferedWriter output = new BufferedWriter(new FileWriter(errorFile));

I am concerned with memory leaks and resource usage, should I simply make it

private BufferedWriter output;

and initialize it/close it within every method, or is initializing it once okay?

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top