P
printdude1968
Hi,
I have a file that looks like this:
..
..
..
<prod>
<d1>
<p1:configuration>
<p1:f1></p1:f1>
<p1:f2></p1:f2>
<p1:f3></p1:f3>
</p1:configuration>
<p2:configuration>
<p2:f1></p2:f1>
<p2:f2></p2:f2>
<p2:f3></ps:f3>
</p2:configuration>
</d1>
<d2>
..
..
..
..
</d2>
</prod>
<dev>
<d1>
<p1:configuration>
<p1:f1></p1:f1>
<p1:f2></p1:f2>
<p1:f3></p1:f3>
</p1:configuration>
<p2:configuration>
<p2:f1></p2:f1>
<p2:f2></p2:f2>
<p2:f3></ps:f3>
</p2:configuration>
</d1>
<d2>
..
..
..
..
</d2>
</dev>
I know this looks like xml but please bear with me...
Here is my java command
java parseControl prod d1 p1
^ ^ ^
environment_| | |
destination_____ | |
printer_____________|
And what I need for I/O is something like this
Start at the beginning of the file
Search forward until I find <prod>
Now search forward until I find <d1>
Now search forward until I find <p1>
And this is where I start processing until I no longer have a <p1> <--
this is a while loop of some sort?
I have the code written for the main processing loop
while (i still have a <p1> )
{
String testString=s.trim();
pcArrayList.add(testString);
}
In fact my code was doing fine until I introduced the destination piece
(yeah bad upfront design on my part)
Once my pcArrayList is loaded, parsing it for what I need is easy and
works... but I just can't figure out how to load the array based on the
required search criteria.
Is there an easy way to do this?
FileInputStream and FileReader don't seem to lend themselves to
stopping and starting...they seem to be more oriented to a continuous
pass. I could probably do this in 4 passes of the file
1) Read each line and if <proc> then set linecount1 to current line
number (counter)
2) Read each line and ignore all that have a line number <= linecount1
and if not then check for "<d1>"
etc
But this is not very pretty and if I can't do what I need with some
degree of speed and elegance using java, I may as well go back to a
purly ksh and awk implementation which means I've wasted 2 days
I have a file that looks like this:
..
..
..
<prod>
<d1>
<p1:configuration>
<p1:f1></p1:f1>
<p1:f2></p1:f2>
<p1:f3></p1:f3>
</p1:configuration>
<p2:configuration>
<p2:f1></p2:f1>
<p2:f2></p2:f2>
<p2:f3></ps:f3>
</p2:configuration>
</d1>
<d2>
..
..
..
..
</d2>
</prod>
<dev>
<d1>
<p1:configuration>
<p1:f1></p1:f1>
<p1:f2></p1:f2>
<p1:f3></p1:f3>
</p1:configuration>
<p2:configuration>
<p2:f1></p2:f1>
<p2:f2></p2:f2>
<p2:f3></ps:f3>
</p2:configuration>
</d1>
<d2>
..
..
..
..
</d2>
</dev>
I know this looks like xml but please bear with me...
Here is my java command
java parseControl prod d1 p1
^ ^ ^
environment_| | |
destination_____ | |
printer_____________|
And what I need for I/O is something like this
Start at the beginning of the file
Search forward until I find <prod>
Now search forward until I find <d1>
Now search forward until I find <p1>
And this is where I start processing until I no longer have a <p1> <--
this is a while loop of some sort?
I have the code written for the main processing loop
while (i still have a <p1> )
{
String testString=s.trim();
pcArrayList.add(testString);
}
In fact my code was doing fine until I introduced the destination piece
(yeah bad upfront design on my part)
Once my pcArrayList is loaded, parsing it for what I need is easy and
works... but I just can't figure out how to load the array based on the
required search criteria.
Is there an easy way to do this?
FileInputStream and FileReader don't seem to lend themselves to
stopping and starting...they seem to be more oriented to a continuous
pass. I could probably do this in 4 passes of the file
1) Read each line and if <proc> then set linecount1 to current line
number (counter)
2) Read each line and ignore all that have a line number <= linecount1
and if not then check for "<d1>"
etc
But this is not very pretty and if I can't do what I need with some
degree of speed and elegance using java, I may as well go back to a
purly ksh and awk implementation which means I've wasted 2 days