wood burning stoves 2.0*
The moose likes Servlets and the fly likes string tokenizer inservlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "string tokenizer inservlets" Watch "string tokenizer inservlets" New topic
Author

string tokenizer inservlets

anand chawla
Ranch Hand

Joined: Oct 19, 2000
Posts: 91
Hi I am working on a program where in I have to separate all the <TR> of html file.
but the thing is that its not perfectly matching all <TR> instead taking in consideration all T....in file.
I mean the string tokenizer delimeter which i m giving as <TR> is recognising T also .I want it to match only <TR>
heres the code plese help
import java.util.*;
class stest {
public static void main(String args[]) throws Exception {
BufferedReader fread=new BufferedReader(new FileReader("ab.txt")); do
{
String line=fread.readLine();
if(line!=null)
{
String delim1="<TR>";
StringTokenizer st = new StringTokenizer(line,"<TR>");
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}
}
else
{
break;
}
}while(true);
}
}
----------------
tell me the solution of this
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
StringTokenizer evalutes on Characters. When you give it a String such as "< TR >" It will tokenize on any of the Characters < , T , R , or >. If you want different functionallity, you have to implement it yourself. You can use indexOf methods in String to determine the locations of the < tr > elements and use substring to remove the data you need.
------------------
Hope This Helps
Carl Trusiak


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: string tokenizer inservlets
 
Similar Threads
Word Counter - just count odd lines?
File Input Stream
Does File Uploading in Struts ignore Tab characters
reverse the text file and write
how to convert .csv files into sql server files using java