• Post Reply Bookmark Topic Watch Topic
  • New Topic

streamtokenizer  RSS feed

 
maggi sesh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
Please do send me some suggestions to solve this problem.
The inputfile i'm trying to read has 4 fields and looks like this
Tg5_Tg0 Genename1 I 3.5
Tg5_Tg2 Genename2 I 2.5
I have used a stream tokenizer to read each field for me. I read the first token as a string.However the nexttoken() method has recognised the Tg5 and has considered the underscore as a separate token. I do not want my program to consider the underscore character as a delimiter .
Is there a way to read my first field Tg5_Tg0 as a whole string. Please do let me know
thanks
maggi
 
Ron Pac
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Try the code below:
<pre>
import java.util.*;
class STExample {
public static void main(String args[]) {
String someString = "Tg5_Tg0 Genename1 I 3.5";
String currString = null;
StringTokenizer st = new StringTokenizer(someString, " ");
System.out.println(st.nextToken());
System.out.println(st.nextToken());
System.out.println(st.nextToken());
System.out.println(st.nextToken());
}
}
</pre>
[This message has been edited by Ron Pac (edited December 26, 2000).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!