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:
parent
e98d42790a
commit
658fd08d20
10 changed files with 30 additions and 69 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue