Sta*_*ego 15 android try-catch suppress-warnings
我有这段代码
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();
}
}
Run Code Online (Sandbox Code Playgroud)
产生恼人的警告"尝试可以使用自动资源管理".问题是我不能使用Java 7 try-with-resources导致我的应用程序目标api级别14(如果我使用它会出错).有没有办法压制那令人讨厌的警告?
Sta*_*ego 27
@SuppressWarnings("TryFinallyCanBeTryWithResources")做了诀窍:)
| 归档时间: |
|
| 查看次数: |
3417 次 |
| 最近记录: |