jdk/test/java/io/FileOutputStream/AtomicAppend.java
changeset 8559 826c03991926
parent 5506 202f599c92aa
child 9035 1255eb81cc2f
--- a/jdk/test/java/io/FileOutputStream/AtomicAppend.java	Tue Mar 01 12:03:44 2011 +0000
+++ b/jdk/test/java/io/FileOutputStream/AtomicAppend.java	Tue Mar 01 15:05:32 2011 -0800
@@ -47,12 +47,12 @@
             for (int i = 0; i < nThreads; i++)
                 es.execute(new Runnable() { public void run() {
                     try {
-                        FileOutputStream s = new FileOutputStream(file, true);
-                        for (int j = 0; j < 1000; j++) {
-                            s.write((int) 'x');
-                            s.flush();
+                        try (FileOutputStream s = new FileOutputStream(file, true)) {
+                            for (int j = 0; j < 1000; j++) {
+                                s.write((int) 'x');
+                                s.flush();
+                            }
                         }
-                        s.close();
                     } catch (Throwable t) { unexpected(t); }}});
             es.shutdown();
             es.awaitTermination(10L, TimeUnit.MINUTES);