首页 > 其他 > 详细

File

时间:2020-04-02 18:17:03      阅读:62      评论:0      收藏:0      [点我收藏+]

获取输出out路径

this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath()

读取文件

//File
File file = new File(this.getClass().getResource("/line_counter_test.txt.gz").toURI());
//Stream
InputStream in = this.getClass().getResourceAsStream("/line_counter_test.txt”);

统计文件大小--不支持压缩文件

//统计文件行数,效率慢,且只能获取非压缩文件
Files.lines(Paths.get(new File("e://test.fa").getPath())).count();

对比文件内容--不支持压缩文件

//对比文件内容
assertTrue(FileUtils.contentEquals(resourceFile, resultFile));

 

File

原文:https://www.cnblogs.com/anna-blog/p/12621242.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!