interesting problem
Hi!
I've got code which changed text from BufferedReader and save in another txt file, thats the sample of the text from txt file
some text one, two, 3,4...
another line of text
and another
some text one, two, 3,4...
another line of text
and another
.....some text one, two, 3,4...
.....another line of text
.....and another
.............some text one, two, 3,4...
.............another line of text
.............and another
some text one, two, 3,4...
another line of text
and another
when i seesome i add something before this line and everything works fine but i have to add something else whensome is in other clolumn, so i need to get position from the firssome and i will be able to compare wih anothersome and do something different with this paragraph.
I need somethin like getCaretPosition but for BufferedReader
that's my code i hope my question will be more clear now.
Sorry for my english.
Any halp will be appreciate.
import java.io.FileReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.*;
import javax.xml.transform.stream.StreamResult;
publicclass FileSearcher{
publicstaticvoid main (String[] args)throws IOException{
String line;
String files="Doc.txt";
StringTokenizer tokenizer;
BufferedReader inFile =new BufferedReader (new FileReader(files));
PrintWriter out =new PrintWriter(new FileWriter("NewDoc.txt"));
while (inFile.ready()){
line = inFile.readLine();
tokenizer =new StringTokenizer(line);
while(tokenizer.hasMoreTokens()){// loops through each token in line
String word = tokenizer.nextToken();
if (word.equals("some"))// we are searching for the String word
{
out.println(" add text before SOME");
out.println(line);
}
/*i think, somethin should be here, like:
*
* if("some is in other column){
* out.println("add diffren text before SOME");
* }
* */
}
out.println(line);
}
inFile.close();
out.close();
}
}

