You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ma...@apache.org on 2021/10/01 11:57:12 UTC

svn commit: r1893778 - /poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/util/DoubleByteUtil.java

Author: mariusvolkhart
Date: Fri Oct  1 11:57:12 2021
New Revision: 1893778

URL: http://svn.apache.org/viewvc?rev=1893778&view=rev
Log:
Replace explicit close with try-with-resources

Modified:
    poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/util/DoubleByteUtil.java

Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/util/DoubleByteUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/util/DoubleByteUtil.java?rev=1893778&r1=1893777&r2=1893778&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/util/DoubleByteUtil.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/util/DoubleByteUtil.java Fri Oct  1 11:57:12 2021
@@ -44,13 +44,13 @@ public class DoubleByteUtil
      */
     public static String cp950ToString(byte[] data, int offset, int lengthInBytes) {
         StringBuilder sb = new StringBuilder();
-        LittleEndianCP950Reader reader = new LittleEndianCP950Reader(data, offset, lengthInBytes);
-        int c = reader.read();
-        while (c != -1) {
-            sb.append((char)c);
-            c = reader.read();
+        try (LittleEndianCP950Reader reader = new LittleEndianCP950Reader(data, offset, lengthInBytes)) {
+            int c = reader.read();
+            while (c != -1) {
+                sb.append((char) c);
+                c = reader.read();
+            }
         }
-        reader.close();
         return sb.toString();
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org