1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-12 14:01:08 +01:00

Use try-with-resources where possible

and make StanzaCollector implement AutoCloseable.
This commit is contained in:
Florian Schmaus 2019-02-04 09:36:37 +01:00
parent e98d42790a
commit 658fd08d20
10 changed files with 30 additions and 69 deletions

View file

@ -491,9 +491,7 @@ public final class VCard extends IQ {
}
private static byte[] getFileBytes(File file) throws IOException {
BufferedInputStream bis = null;
try {
bis = new BufferedInputStream(new FileInputStream(file));
try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) {
int bytes = (int) file.length();
byte[] buffer = new byte[bytes];
int readBytes = bis.read(buffer);
@ -502,11 +500,6 @@ public final class VCard extends IQ {
}
return buffer;
}
finally {
if (bis != null) {
bis.close();
}
}
}
/**