Hi,I hope someone will help me because I have a problem. I have 2
files.txt. I have to take one element contained in a row of the first
file and find it in the second file.
If in the second file I find the element I want copy the row in which
there is the element and the 9 previous rows. So, in the second file I
will be 10 rows; the last
rows contained my element.
void WriteData (String GPSCANfile,String SPHfile)
{
try
{
BufferedReader gpscanf = new BufferedReader (new FileReader
(GPSCANfile));
BufferedReader sphf = new BufferedReader (new FileReader
(SPHfile));
BufferedWriter file = new BufferedWriter (new FileWriter
("Data.txt"));
.........
}
Someone can help me,please????
Thanks everybody
> Hi,I hope someone will help me because I have a problem. I have 2
> files.txt. I have to take one element contained in a row of the first
[quoted text clipped - 20 lines]
> Someone can help me,please????
> Thanks everybody
Just take then entire file you need to search through and drop it into a
linked list of Strings (assuming it is sufficiently small, which it
definitely sounds like it is)
I see the code you cut and pasted, so it looks like you have the majority of
the work done already!
--
LTP
:)
Patricia Shanahan - 19 Jul 2006 22:00 GMT
>> Hi,I hope someone will help me because I have a problem. I have 2
>> files.txt. I have to take one element contained in a row of the first
[quoted text clipped - 27 lines]
> I see the code you cut and pasted, so it looks like you have the majority of
> the work done already!
If it is too big for reading it into a list to make sense, consider
using java.util.Queue interface, with a LinkedList implementation. You
could read the first nine lines and push them onto the queue.
From then on, as you read a line, if it the line you want the queue
contains the nine previous lines you need to output. If it isn't, remove
the first line from the queue and add the new one.
You could effectively do the same thing yourself using a nine element
String array and some circular buffer logic, but it would be a lot more
work.
Patricia
> Hi,I hope someone will help me because I have a problem.
Only you can help that multi-posting problem, by not doing it.
Andrew T.
Luc The Perverse - 19 Jul 2006 18:28 GMT
>> Hi,I hope someone will help me because I have a problem.
> Only you can help that multi-posting problem, by not doing it.
EEk! I tried to help that man - I didn't know that he was an evil multi
poster.

Signature
LTP
for( Base i : allYourBase)
i.AreBelongToUs();