【发布时间】:2016-11-01 06:50:01
【问题描述】:
我有一个带有文本文件(txt 格式)的大型数据集。 文本文件包含这种格式的数据:
Name, Number, Timestamp, Sensordata1, Sensordata2, ... , Sensordata40
Name, Number, Timestamp, Sensordata1, Sensordata2, ... , Sensordata40
Name, Number, Timestamp, Sensordata1, Sensordata2, ... , Sensordata40
现在我需要从每一行中删除数字和时间戳。
我现在的代码:
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("file.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
}
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
如何在 Java 中做到这一点?
【问题讨论】:
-
类似
String.split(',')的东西,获取一个数组并删除你需要的东西
标签: java text-files bufferedreader