Results 1 to 8 of 8
Thread: To read tags from file
- 07-15-2010, 04:18 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 29
- Rep Power
- 0
To read tags from file
From file read the data : <a><c><d>e</d></d></a>
Output: ERROR: Mismatching tags on line 1: <c> and </d>!
Code is:
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;
class Test6{
public static void main(String[] args)throws Exception{
Stack<Character> stack = new Stack<Character>();
BufferedReader br = new BufferedReader(new FileReader("c://test//assignment//input7.txt"));
String s;
int counter=0;
while((s=br.readLine())!=null){
char temp[] = s.toCharArray();
for(int i=0;i<temp.length;i++){
if(Character.isLetter(temp[i])){
...................
......................
.................
}}
}
br.close();
}
}
Could anyone kindly provide any solution for it?? Anything at all.
Or algorithm for it. I think I tried my best, unfortunately still could not do it:(
Pleaseeeeeeeeeeeeeeeeeeeeee!!!!!!!!
- 07-15-2010, 04:35 PM #2
Sounds like you need to keep track of the state of the scan (perhaps by using booleans).
When you find a begin marker, set a flag to remember it.
Then if you find an end marker without having read a begin marker, that would be an error.
When you find the end marker, turn off the begin marker.
You'd probably need a stack to keep the state of the scan organized. The top of the stack would be the current begin marker. As the end was found, pop off the begin.
- 07-15-2010, 04:53 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,604
- Blog Entries
- 7
- Rep Power
- 17
Is this thread a sequel to this one?
kind regards,
Jos
- 07-15-2010, 05:41 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Seems discussing the same in two different threads.
- 07-15-2010, 05:47 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,604
- Blog Entries
- 7
- Rep Power
- 17
- 07-15-2010, 06:01 PM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I've remember that same user ask another related question to this. Have to check in my subscriptions.
- 07-16-2010, 04:36 AM #7
Member
- Join Date
- Jun 2010
- Posts
- 29
- Rep Power
- 0
Yeah, I keep asking same kind of question since no right solution has been found yet.
Can anyone give a piece of code illustrate it. No need to have perfect answer, just need sth to push me to explore further. Thanks
- 07-16-2010, 05:50 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
Read a file and converting this file into a string
By kostinio in forum New To JavaReplies: 7Last Post: 12-26-2009, 03:54 PM -
Read file from directory, update contents of the each file
By svpriyan in forum New To JavaReplies: 2Last Post: 05-11-2009, 10:07 AM -
how to read openproj(Projity) file i.e. ,POD file(Project Management file)
By mahendra.athneria in forum New To JavaReplies: 0Last Post: 02-11-2009, 09:53 AM -
How to read and write to a file without taking out the comments in the file
By MAGNUM in forum New To JavaReplies: 5Last Post: 02-05-2009, 10:28 AM -
How to read a text file from a Java Archive File
By Java Tip in forum Java TipReplies: 0Last Post: 02-08-2008, 09:13 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks