2
I needed to create a reference index with a book passed by parameter (File
, BufferedReader
).
So far I did not get good results, I have only a code that generates a TreeSet
with all words of text passed by parameter. I’ve been trying for 3 weeks to make the code that takes the words and saves the lines where they appear and generates the HTML file of the index.
Read
is a LineNumberReader
, words is a TreeSet
.
I have found problems when going through the list generated by the split method and compare with the text word by word (this is the code that I can not elaborate).
while((line = read.readLine()) != null){
line = line.replaceAll("[^a-zA-Z]", " ").toLowerCase();
split = line.split(" ");
for(String s : split){
if(s.length() >= 1 && !palavras.contains(s)){
palavras.add(s);
}
}
}
path.close();
read.close();
}catch(FileNotFoundException e){
e.getStackTrace();
System.out.println("Caminho para o arquivo invalido!");
}catch(IOException ex){
ex.getStackTrace();
}
return palavras;
}
Did you find a solution? Poste as an answer to help other people.
– Maniero