关闭时是否存在现有FileInputStream删除?

关闭时是否存在现有FileInputStream删除?,第1张

关闭时是否存在现有FileInputStream删除

标准库中没有这样的东西,也没有任何apache-commons库,所以类似:

public class DeleteonCloseFileInputStream extends FileInputStream {   private File file;   public DeleteonCloseFileInputStream(String fileName) throws FileNotFoundException{      this(new File(fileName));   }   public DeleteonCloseFileInputStream(File file) throws FileNotFoundException{      super(file);      this.file = file;   }   public void close() throws IOException {       try {          super.close();       } finally {          if(file != null) {  file.delete();  file = null;         }       }   }}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5429241.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-11
下一篇2022-12-11

发表评论

登录后才能评论

评论列表(0条)

    保存