package test_java;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.List; public class ReadWrite {
public static void main(String [] args) {
String filePath = "input.txt";
String destFilePath = "output.txt";
readWrite(filePath, destFilePath);
} public static void readWrite(String filePath, String destFilePath) {
List<String> report = Arrays.asList("Prevotella_intermedia", "Enterobius_vermicularis", "Parvimonas_micra", "Protopolystoma_xenopodis");
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath)); // 读取文件
FileOutputStream fileOutputStream = new FileOutputStream(new File(destFilePath)); // 写入文件
String string;
while((string = bufferedReader.readLine()) != null) { // 按行读取
if (string.split("\t")[0].trim().equals("species")) {
fileOutputStream.write((string + "\n").getBytes()); // 将符合条件的行写入文件
}
if (report.contains(string.split("\t")[0].trim())) {
fileOutputStream.write((string + "\n").getBytes());
}
}
} catch (IOException e) {
e.printStackTrace();
} }
}

最新文章

  1. 一个virtualbox开机即aborted的问题解决
  2. JSF 与 HTML 标签的联系
  3. 深入理解C语言的函数调用过程
  4. puppet安装
  5. ecshop简单三部实现导航分类二级菜单
  6. In p = new Fred(), does the Fred memory “leak” if the Fred constructor throws an exception?
  7. Foundation与Core Foundation内存管理基本原则简述
  8. Nhibernate 一对一关系映射(主键映射)
  9. Liunx下Tomcat+MYSQL+Nginx配置
  10. thymelef 布局 fragment
  11. 怎么屏蔽F5键刷新功能
  12. struts开发步骤
  13. C#属性和字段
  14. Intellij idea 中修改java web代码 ,网页不同步
  15. C#添加背景音乐
  16. 分布式配置管理平台XXL-CONF
  17. java将一个List赋值给另一个List
  18. Luogu P4009 汽车加油行驶问题
  19. 使用js对WGS-84 ,GCJ-02与BD-09的坐标进行转换
  20. mysql分页优化方法

热门文章

  1. 在Mac 上搭建Linux虚拟机--MacOS &amp; VMware10 &amp; CentOS 7
  2. GitBook基本使用
  3. 【Python3爬虫】最新的12306爬虫
  4. .NET获取实例化对象的部分属性名称
  5. .net core - 配置管理 - json文件配置
  6. 完美转发(perfect forwarding)、universal reference、引用折叠(collasping)
  7. python 双层for循环,在第二层的for循环中的else中的continue,会退出到第一层for循环继续执行
  8. 2019 学霸君java面试笔试题 (含面试题解析)
  9. python--进程初识详解
  10. kubernetes集群内通过endpoint访问外部服务