Replace explicit close with try-with-resources

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1893778 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Marius Volkhart 2021-10-01 11:57:12 +00:00
parent e239fd745f
commit 9994a4286d

View File

@ -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();
}
}