jdk/test/java/io/Serializable/longString/LongString.java
changeset 5809 6e38efd0293f
parent 5506 202f599c92aa
child 7668 d4a77089c587
--- a/jdk/test/java/io/Serializable/longString/LongString.java	Fri Jun 18 09:35:22 2010 -0700
+++ b/jdk/test/java/io/Serializable/longString/LongString.java	Fri Jun 18 20:59:13 2010 +0100
@@ -68,17 +68,25 @@
         mesgf = new File(System.getProperty("test.src", "."), "mesg.ser");
         fin = new FileInputStream(mesgf);
         bout = new ByteArrayOutputStream();
-        while (fin.available() > 0)
-            bout.write(fin.read());
+        try {
+            while (fin.available() > 0)
+                bout.write(fin.read());
+        } finally {
+            fin.close();
+        }
         byte[] buf2 = bout.toByteArray();
 
         if (! Arrays.equals(buf1, buf2))
             throw new Error("incompatible string format (write)");
 
         fin = new FileInputStream(mesgf);
-        oin = new ObjectInputStream(fin);
-        String mesgcopy = (String) oin.readObject();
-        if (! mesg.equals(mesgcopy))
-            throw new Error("incompatible string format (read)");
+        try {
+            oin = new ObjectInputStream(fin);
+            String mesgcopy = (String) oin.readObject();
+            if (! mesg.equals(mesgcopy))
+                throw new Error("incompatible string format (read)");
+        } finally {
+            fin.close();
+        }
     }
 }