Discuss
/
手写Spring
/
将FileSystems.newFileSystem用try-with-resource包裹后运行测试中的scanJar()抛出ClosedFileSystemExcept异常
将FileSystems.newFileSystem用try-with-resource包裹后运行测试中的scanJar()抛出ClosedFileSystemExcept异常
Topic sourcereturn 后,FileSystem被自动close,可能是有其他部分共用了这个FileSystem。例如:Paths中封装了活动Path的工具方法 , 其实现默认依赖于FileSystems
- 1
R8HLR6CC
请问廖老师为什么我将原来代码改成现在这样运行测试代码中的scanJar()方法会抛出java.nio.file.ClosedFileSystemException异常呢,运行scanClass()和scanTxt()是不会的
原
现