Wrox Home  
Search P2P Archive for: Go

  Return to Index  

servlets thread: cutting of Strings


Message #1 by kotreshm_99@r... on Fri, 27 Apr 2001 11:46:09
hi everyone, 
I have written a code to cut the strings. But I am facing some problems in 
StringTokenizer() . It is not accepting some delimiters such as { " and 
space}. 

The program written by me is:

import java.util.StringTokenizer;
class STDemo2
{
static String in="210.18.21.182 - - [26/Feb/2001:01:00:02 +051800] GET 
/professionals/index.htm HTTP/1.0 200 19095; ";
public static void main(String args[])
{
StringTokenizer st=new StringTokenizer(in," ");

while(st.hasMoreTokens())
{
String key=st.nextToken("[]+/ ");
String val=st.nextToken();
System.out.print(key + "\t " + val );
}
}
}

How to overcome this problem.Please suggest solution.

Thanks in advance



  Return to Index