Skip to content

Commit 1f1a53a

Browse files
committed
Use Java 11 methods to simplify FeatureClassLoader.
1 parent 2fe1bb2 commit 1f1a53a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/src/main/java/com/diffplug/spotless/FeatureClassLoader.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,8 @@ public URL findResource(String name) {
101101

102102
private static ByteBuffer urlToByteBuffer(URL url) throws IOException {
103103
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
104-
int nRead;
105-
byte[] data = new byte[1024];
106-
InputStream inputStream = url.openStream();
107-
while ((nRead = inputStream.read(data, 0, data.length)) != -1) {
108-
buffer.write(data, 0, nRead);
104+
try (InputStream inputStream = url.openStream()) {
105+
inputStream.transferTo(buffer);
109106
}
110107
buffer.flush();
111108
return ByteBuffer.wrap(buffer.toByteArray());

0 commit comments

Comments
 (0)