I have this piece of code
private void copyFile(File src, File dst) throws IOException {
FileChannel inChannel = new FileInputStream(src).getChannel();
FileChannel outChannel = new FileOutputStream(dst).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
}finally {
if(inChannel != null) {
inChannel.close();
}
outChannel.close();
}
}
that generates the annoying warning "try can use automatic resource management". The prolem is I cannot use Java 7 try-with-resources cause my app targets api level 14 (got an error if I use it). Is there a way to suppress that annoying warning?
@SuppressWarnings("TryFinallyCanBeTryWithResources") did the trick :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With