
标准库中没有这样的东西,也没有任何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; } } }}欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)