我想在文本文件中搜索特定单词并将该单词存储在数组列表中。我已经这样做了,但它会给出文本文件中是否存在类似单词的输出。我想将该文本存储在数组列表中
double count = 0, countBuffer = 0, countLine = 0;
String lineNumber = "";
String filePath = "D:\\PDFTOEXCEL\\Extractionfrompdf.txt";
BufferedReader br;
String inputSearch = "Facture";
String line = "";
try {
br = new BufferedReader(new FileReader(filePath));
try {
while ((line = br.readLine()) != null) {
countLine++;
//System.out.println(line);
String[] words = line.split(" ");
for (String word : words) {
if (word.equals(inputSearch)) {
count++;
countBuffer++;
}
}
if (countBuffer > 0) {
countBuffer = 0;
lineNumber += countLine + ",";
}
}
br.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
拉风的咖菲猫
梵蒂冈之花
相关分类