C# supports disposable pattern for deterministic garbage collection using the dispose pattern.
Is there such pattern for java?
Java 7 has autoclosable, whic
What you are looking for is try with resources.
try ( FileInputStream input = new FileInputStream(...); BufferedReader br = new BufferedReader(...) ) { // Use input }
The resource has to be Closeable (or AutoCloseable), of course.