• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

string tokenizer inservlets

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic