UF.OUT

当尝试使用已被释放的资源时,就会报告 UF(使用已释放)问题。UF.OUT 警告表明尝试在输出流已被关闭后使用它。

示例 1

复制
     public boolean writeMeta(OutputStream stream) {
         try {
             stream.write("mystate".getBytes());
         } catch (IOException e) {
             return false;
         } finally {
             try {
                 stream.close();
             } catch (IOException e) {
                 // do nothing
             }
         }
         return true;
     }
 
     public void saveState(final String path, final byte[] data) throws IOException {
         final FileOutputStream stream = new FileOutputStream(path);
         if (writeMeta(stream)) {
             stream.write(data);
         }
     }

针对第 33 行的代码段报告 UF.OUT:使用了已在第 22 行关闭的输出流 stream。