Code example for Closer

Methods: close

public class MorphEncodingToolTest extends RandomizedTest { 
    private Closer closer = Closer.create();
    public void cleanup() throws IOException {
	public void testTool() throws Exception {
		// Create a simple plain text file. 
		File input = super.newTempFile();
		File output = super.newTempFile();
		// Populate the file with data. 
		PrintWriter w = 
		    new PrintWriter(
		        new OutputStreamWriter(
		            closer.register(new FileOutputStream(input)), "UTF-8"));
Contextual code suggestions in your IDE  Get Codota for Java