File

获取输出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));

 

posted @ 2020-04-02 17:34  Anna_blog  阅读(80)  评论(0)    收藏  举报