我有这样一段代码Android的API级别<19和“尝试可以使用自动资源管理”警告
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();
}
}
产生恼人的警告“可以尝试使用自动资源管理”。该问题是我不能使用Java 7尝试与资源导致我的应用程序目标API级别14(如果我使用它会得到一个错误)。有没有办法抑制这个令人讨厌的警告?
使用SuppressLint –
和我应该使用什么样的ID?我不想使用“全部”.. –