Java - XStream 关闭与文件的连接
我像这样加载 XML:
File f = new File("Results\\" + filename);
xstream.fromXML(f);
Boolean delete = f.delete();
成功使用 XStream 后,我想删除我的文件。我无法这样做,因为 XStream 仍处于打开状态,因此无法删除我的文件。如何关闭连接并删除文件?
I load my XML like this:
File f = new File("Results\\" + filename);
xstream.fromXML(f);
Boolean delete = f.delete();
After using XStream successfully I want to delete my file. I am not able to do so because XStream is still open and so my file can't be deleted. How can I close my connection and delete my file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果抛出异常,则输入流将被正确关闭。如果一切正常,InputStream 将在finally 块中正确关闭。
If an exception was thrown, the inpuStream would be closed correctly. And if everthing works fine - the InputStream would be closed corretly within the finally block.