Question

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?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top