String Tokens

Hi All
Iam getting input as
testdata = "ABC|123"
iam using
StringTokenizer = new StringTokenizer(testdata, "|");
This is giving me just the first value which is ABC.
I need values before and after the delimiter.
Any help is appreciated

Hi Thanks for response
String testdata = "ABC|123";
StringTokenizer tok = new StringTokenizer(testdata, "|");
while (tok.hasMoreTokens())
{    System.out.println(tok.nextToken());}
This works, but its working only for the first part of the string, i,e ABC, how can i get values after the token?
i mean 123, i hope iam making sense.
Thanks

Similar Messages

  • Guys I need some help. String token of a wired message

    well this is my code.
    code:
    import java.*;import java.util.StringTokenizer;import java.io.*; class stringtoken {         public static void main(String[] args) {         Runnable daemonRunner = new Runnable()        {                public void run()                        {                         while (true)                                {                    String red, green, blue, yellow, brown, v6, v7;                                        int ali=42;                                         String origtext = "accaa*b*dzddsf*,.sfsdf,a.a/.d,asd.,fa.a/.,/.**asdasdaadf";                                        StringTokenizer st = new StringTokenizer(origtext,"*");                                        try {                                        red = (String)("a" + st.nextToken());                                         green = (String)(st.nextToken());                                        blue = (String)(st.nextToken());                                        yellow = (String)(st.nextToken());                                        brown = (String)(st.nextToken());                                         System.out.println("Red : " + red);                                        System.out.println("Green : "+ green);                                        System.out.println("Red : " + blue);                                        System.out.println("Green : "+ yellow);                                        System.out.println("Blue : " + brown);                                        /////////////////////////////////[shaded section]/////////////////// String red1,red2;int ie=41; String aChar1 = new Character((char)ie).toString(); System.out.println("From above : Red" + red + " *** Will token -> " + aChar1); StringTokenizer st1 = new StringTokenizer(red, ")"); try {                                                red1 = (String)("After splitting 1 :" + st.nextToken());                                                red2 = (String)("After splitting 2 :" + st.nextToken());                                                System.out.println("Output : " + red1 + "&" + red2 );                                                        } catch (Exception ignored) { // (ERROR STATE) could not parse it                                                        } ////////////////////////////////[end of shaded section]/////////////////// int a = 0x41;int i=65; String aChar = new Character((char)i).toString(); System.out.println("Ending : " + aChar); } catch (Exception ignored) { // (ERROR STATE) could not parse it                                        } try {                                                Thread.sleep(1500);                                        } catch (InterruptedException ignored ) {                                        } } } }; Thread daemonThread = new Thread(daemonRunner); daemonThread.setDaemon(false); daemonThread.start(); try {                Thread.sleep(1000);                } catch (InterruptedException ignored) {                } } }
    let me explain a lil. The program is actually a daemon. It works fine. In the body run, that's the thingy which did string token. It works fine. But
    i am creating something that will split (1a) into 2 piece, and another will spilt the other piece.
    The senario, the daemon will receive a string, like "*abcde,1,2,3,hello%"
    where * = STX (ASCII 02) and % ETX (ASCII 03)
    the first loop will eliminate the STX, then seggregate the text to a loop, for example a=abcde, b=1, c=3, d=hello%.
    *what i managed to do is only string token the normal characters, not the ASCII characters 
    then the final loop will grab strtoken the % char.
    i have been trying tht for 1 whole days.. n e ideas guys ?
    thanks in advance.
    you could also post the edited text to [email protected]

    I have solve the problem. Thanks guys!
    import java.*;
    import java.util.StringTokenizer;
    import java.io.*;
    class stringtoken1 {
    public static void main(String[] args) {
         Runnable daemonRunner = new Runnable() {
              public void run() {
                        while (true) {
                        int STX=2, ETX=3, comma=44;
                        String stx = new Character((char)STX).toString();
                        String etx = new Character((char)ETX).toString();
                        String flag= null;
                        String ID= null;
                        String date= null;
                        String location= null;
                        String mobile= null;
                        String outtouser= null;
                        String message1=null;
                        String message2=null;
                        String origtext = stx+"1,001,17062005 16:16:16,Rawang, Telekom, Please stand by "+etx;
                        //System.out.println(origtext);
                                            String throwstx = new Character((char)STX).toString();
                                            StringTokenizer stxthrow1 = new StringTokenizer(origtext, throwstx);
                                            try {
                                                  message1 = (String)(stxthrow1.nextToken());
                                            catch (Exception ignoredthrowstx) {System.out.println(ignoredthrowstx);}
                                            String throwetx = new Character((char)ETX).toString();
                                            StringTokenizer etxthrow = new StringTokenizer(message1, throwetx);
                                            try {
                                                       message2 = (String)(etxthrow.nextToken());
                                            catch (Exception ignoredthrowstx) {System.out.println(ignoredthrowstx);}
                                            String chomma = new Character((char)comma).toString();
                                            StringTokenizer st = new StringTokenizer(message2,chomma);
                                            try {
                                                      flag = (String)(st.nextToken());
                                                      ID = (String)(st.nextToken());
                                                      date = (String)(st.nextToken());
                                                      location = (String)(st.nextToken());
                                                      mobile = (String)(st.nextToken());
                                                      outtouser = (String)(st.nextToken());
                                            catch (Exception ignoredcomma) {System.out.println(ignoredcomma);}
                                            System.out.println("Original Message : " + origtext);
                                            System.out.println("After STX : " + message1);
                                            System.out.println("After ETX : " + message2);
                                            System.out.println("Filtering");
                                            System.out.println("flag : " + flag);
                                            System.out.println("id : "+ ID);
                                            System.out.println("date : " + date);
                                            System.out.println("location : "+ location);
                                            System.out.println("mobile : " + mobile);
                                            System.out.println("message : " + outtouser);
                             try {
                              Thread.sleep(3000);
                              catch (InterruptedException ignored ) { }
    Thread daemonThread = new Thread(daemonRunner); daemonThread.setDaemon(false);
    daemonThread.start();
    try { Thread.sleep(1000);}
    catch (InterruptedException ignored){ }
    }for others guys as well :)

  • String Tokenizing Question

    Hello -
    I'm able to tokenize w/o any problems, save for when I run into consecutive instances of the character, a comma, that I am using for my delimiter. Here's a sample line:
    The,lazy,fox,,jumped,,,over,the,,,moon,,,,,
    So, if my string has values for each field that the tokenizer looks at, I have no problems, but if there are two or more commas (delimiters) in sequence, it breaks the tokenizer.
    So what I'd like to do barring a better/simpler solution is to print "N/A" or something if there is no data in that token and then continue on to assign each (valid) token to a String variable.
    Thanks...

    Like warnerja suggested/mentioned: try String's
    split(...) method:
    String s =
    "The,lazy,fox,,jumped,,,over,the,,,moon,,,,,";
    String[] tokens = s.split(",+");
    for(int i = 0; i < tokens.length; i++) {
    System.out.println("Token "+(i+1)+" =
    "+tokens);
    Except get rid of the "+" part, as that just makes it eat the empty tokens. Just use s.split(",")                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Split/remove characters for a string token

    How can a string token i.e. 2-234-56723-4 have the - removed so that the token is left with 2234567234?
    I tried to split it using "-" but that obviously doesnt work, because 234 will be a token, I just want to remove the - from the token.
    advice please.

    endasil wrote:
    Implode wrote:
    if I want 3-34-565456-4 to be 334565456 so that I can take each digit and do calculations with them, could I just split the string 334565456 using .split(""); which will give me splitArray[0]=3, splitArray[1] = 3, splitArray[2] = 4 etc.
    String someStr = "3-34-565456-4";
    String numsOnly = someStr.replaceAll("-", ""); //or someStr.replaceAll("[^0-9]", "");
    for ( char c : numsOnly.toCharArray() ) {
    int digit = c - '0';
    }Or
    for ( int i = 0; i < numsOnly.length(); i++ ) {
    int digit = Integer.parseInt(numsOnly.substring(i, i+1));
    What is "digit" ? and doesn't it re-assign a new number to digit each iteration?
    Im not sure how I will access each digit.

  • Comparing input from command line to a String token problem

    Hi,
    I want to compare my input from the command line to a token.
    my command line looks like "java myProgram george bush president washington"
    The next command could be "java myProgram geoge president washington"
    Basically I have a text file which has a name, job and location field. The text file looks as follows
    jim, farmer, chicago
    paul, builder, texas,
    george bush, president, washington
    I am using string tokenizer with a "," as my field delimiter.
    My lecturer wants me to take the input from the command line so applets are out of the question. However even though there are 3 fields, args.length() could equal 4 because "george bush" is only the name but george is args[0] and bush is args[1]. Is there a way to have a delimiter on the command line instead of a space such a ",". Can anyone see any other way around this?
    Thanks

    1982. The year of.....wait for it.....
    Jack And Diane
    Tainted Love
    Key Largo
    Open Arms
    Do You Believe In Love
    Gloria
    Working For the Weekend and of course the GREATEST song of 1982...
    drum roll please......
    Heat Of The Moment.

  • Search text file with 2 string tokens

    I am reading a text file which contains database records. I am able to search with lastname(the user enters it in the textfield using GUI frontend). this search useus stringtokenizers. take the users input and search all the tokens and see which token matches the key and prints that record. Can someone please give me some advice to do a search using both last name and first name at the same time. In this case i will have to do a seach using 2 tokens which i dont know how to do. thanks.

    Here is the snippet of my code. Can someone please take a look at it.
    while ( (dbRecord = dis.readLine()) != null) {
    StringTokenizer st = new StringTokenizer(dbRecord, ":", false);
    Vector row = new Vector();
    String lineTemp;
    while (st.hasMoreTokens()) {
    if (st.nextToken().trim().equalsIgnoreCase(userinput)) {
    //System.out.println(dbRecord);
    StringTokenizer tempst = new StringTokenizer(dbRecord, ":", false);
    while (tempst.hasMoreTokens()){
    row.addElement(tempst.nextToken());
    dataVector.addElement(row);
    }

  • Scan String Token Problem with leading Tokens

    Hi, I'm using the scan string for token to read in a string of tokens that contain a leading "*" char in front of each string and terminates when the token index = -2. This works great if I have say *12345*1234 and so forth, but if there is bad data, say 1234 without the leading "*" in front, the token index return value is still -1 and it returns data which I read in thinking it found the "*". Maybe I shouldn't use the string for token function since it's probably just designed for ending tokens and not data with leading tokens. Is there a way to make this work properly or should I use another method to search for leading tokens in a string?
    Thanks.
    Solved!
    Go to Solution.

    Here.  Try this one.  It does the same thing and uses exposed functions.
    The string functions look for something to mark the end of a string.  All languages that I know of do this.  So, like I said, remove the first element.  I recommend the Subarray function with the index set to 1 and length unwired.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Parse Message.png ‏10 KB

  • Urgent help reqd in string tokenizing

    hi all,
    i want to count the number of commas in the screen,
    ths is my code
    import java.util.*;
    class TokenizerTest
         public static void main(String[] args)
    String str= new String("REMOVE_STR,01,6403,40,143,990,410,,,11,ATTN PAT COLEMAN,, ,,,N,,,,,,,,,,,NC,,,,,");
         StringTokenizer st= new StringTokenizer(str,",",false);
         int i=0;
         while(st.hasMoreTokens())
              System.out.println(st.nextToken()+" Val :"+i);
              i++;
         System.out.println("Value of i"+i);
    System.out.println("Count is " +st.countTokens());     
    }but its notgiving the proper count... those commas whcih are not separated by spaces orcharacter, it desn't count like" ,," it won't count theese commas it works fine when commas are separated by spaces or charachters.
    what is the solution for this?.. plz help me its urgent
    Thanx in advance
    Deepali

    countTokens() should have been called before the while loop.
    so, System.out.println("Count is " +st.countTokens()); should be place before the while loop or create
    a local int variable to store the count and use the variable in the
    System.out.println("Count is " + count);
    The reason why you're not getting the proper count is this:
        In the while loop..you use nextToken()..when this method is called..countToken() method count the total
        number of token left; therefore...after the while loop..countToken() will always return ZERO.
        you should use the String split(String regex) function, if you are using the jdsk 1.4 or higher.
    public static void main(String[] args) {
        String str= new String("REMOVE_STR,01,6403,40,143,990,410,,,11,ATTN PAT COLEMAN,, ,,,N,,,,,,,,,,,NC,,,,,");
        String s[] = str.split(",");  // require jdk 1.4
        // NOTE:   the String "a,,b"      - two commas return
        //    s[0] = "a"    
        //    s[1] = "";    // empty string
        //    s[2] = "";    // empty string
        //    s[3] = "b";
        for (int i = 0; i < s.length; i++)
            System.out.println("Value of i = " + s);
    System.out.println("Count is = " + (s.length - 1) );

  • Big String token... value changes while passing

    Hi All,
    Iam trying to create a token and pass it across layers..
    the token is a String and when i pass it and receive it there the content of the token is getting changed.
    kindly give me a solution..
    The token is very large.
    Tks

    Token is the Session Created unique Id...
    Its a String,
    bNrqb3fqrgHOnkGJc6aSiiT8mBv8oiaOqALvnhOXl71KmhbIqBaRc5uO+QbaaiX6rj9hb4GXdjLPrjjDbz55rRiRgifiiRbwn51khiCKdhPqik56piDlaQDUr6bzmN1LbzfCi51egNOXl51OoArMkB4Jq71/hjDDhhnLpl1Cs30XdjLfpxr5/OPFnAfCpiPQaAjLb5bOiiaKdhPqjQrvgB8Ok68TbPrbskiQnAPCbzrngNOXl6nbqkX9hPfDqi92szr7gB9gjzrLj7iXdjLyoB4TfOvTnPv3oBDamkHcrx53+QaKdhPqgzrQoADDqiuTn6Pdhxznblb/q6nenhOXl38Rsx5IqMWJbBb5q31BqQLPi3yJaQiXdjLor4j3/QrHrzzbaACFchz6/N9cbz8KdhPqb6nLkyfMgxn7k51ijlzxiQ55o4OPa3OXl4HkpjbkqRD9pB5FfRjxn3bB+PuOgBiXdjLhpl0JmRrjhxv3hOn4qk4RaN96bQH/dhPqii9zchr4b45LqyHinkzOf4STnOz5a3OXl7qRfR1FbyLCc7fFokHGbj5jq4LefAiXdjLcoBbFqAb5jBmMr30QoAXJrl1BaiTPdhPqfiXoriiRizvMqkPMs7zJhj1JckvenhOXl6XHnAD4iyDFj5zgi35/j48T+N1Oex0XdjKLc5zEeO5Sohfbp4qFmOHLk2XFbyiKdhPqkir5fOjikkbCj7fTqOzfnOH+pQ9enhOXl7nkjPqRfPzks5jyaBnMh4uSgRyKbyGXdjKPoO9M+P1Bh79DnOjyoPiLexvPrOjzdhPqmQrMiQHAqQLEoP4LrQjnq6uRehfSnhOXl6DhoRf4hkLRrjqLs6rJqOzvnkncekiXdjLJo6rjmNnQsk9T+NbwayjneBbBpAX/dhPqg74LsjnMeRDLizqLjQPdiAr+gknTgNOXl31OnifHq6jlml55aR1fajf4bhmLoRiXdjLhmRvNq3eRgP15b51+mOHejyORhybPdhPqhzaSazn1qjz//O5CjOHHnyzyi4jwa3OXl6n9oMXngR5KiAXRj2HojBnno6D9h4GXdjLQpiDKa4DHmN5Jg5DSrh9KpOLCr4n/dhPqnRvP+R9+giqQhzuTjkfvfhaPeyP1a3OXl55/jingmkz++N8Jal5PaizNbjbUsBiXdjLT+Qbkg7D5plzin6v/nQzNr65GqiqKdhPqnkbhnl1Rn39lj4OQpRfniyLKfzvAa3OXl6aSgz5SclrF/OaOoxzOh69oo658hOGXdjLSfkn+iAH3pzrkpATfkzaFjBz7qzvPdhPqmN93pzff/OzlfNngrh5xk3fAggHAa3OXl7j2nkjD/QX9pBCRah4PayOJpx99o6iXdjKMgkLDiOfKmi9xp6D9j5yPj715jiP/dhPqgBnkaN4LgAnajMXnn5rajOT9qO9erhOXl4XSmwGLhiqJaMXBsBbCh2XMnyHGrBiXdjK=
    This iam passing to the remote EJB. Where its reflecting to me like this.
    bNbqb3fqb5blqQ9ibN8J/Nb5nRDxfh9ooNbSrhOXl6j8k4X9n7nofhvn+Nfdn7uToAbdr4GXdjLMayndphrfrNiQjN1ipkjHfxz7fzn/dhPqpxf5kib9cgHziwHxi3iJfQXmeQbigNOXl2X9qwWQ/R5jrxfcbkvjpBfB+OXakyGXdjLQc4zUezj9ryXDmxzH/Nn5iQzhpN8KdhPqeAP9jBrUg4jLfOqSrkLmp6jgml9xnhOXl6XHekTMo3v3rRfMmO5RqlqLqxz5qQiXdjLOeNnleQ5Nc7b9ok9brRrAezr6ckH/dhPqhkTDgBnjoiXHg7DLoBb+rkvGpj59rhOXl6jQeiTTakb+/Pbkg4DKchnQp6rIeh0XdjLfrQjknBzxmh1npP9Bp2WQs3zTnkfPdhPqoPfLo4vCiOHGfQnyrAj/qOr4qRn5a3OXl6GFgAPLc7zir558hlf8njf9bN5UpkiXdjLOfR0JrAvbeiHogl1EgkGLjNj3gx5zdhPqixvDj55ApzbPeRbia5zIrRbRej9fgNOXl7vefx5eq7uSs6r2o7iTa3v8hz1ojOGXdjLhmADbmNvdo6TNa4WQg3rwc6OTnP1PdhPqqz0SfAHxqiv3a6PMjMHfjzjwg4nbrhOXl2H4a3fUqlrbk4HNhQH9bR9Gpk52oN0XdjLxpjjNfynzmwXdsjvDfluFekHv+N5zdhPqnxzSg3r1bx8PpyHgjzvkr3fmjxiOrhOXl458pwXUhRj8ozb+gyrAqkXInRz5q7iXdjLKihyLg4DQoOGJc6bSkBjxo6SLghbPdhPqpyyNrQyKc2X8fyyMaknFj5zLo657gNOXl49xp4H/jymQalnar6LHbxfChP1co6iXdjKShO9K+NvHeQ9ToNvHaBmFi5aLkymKdhPq+OvQbOLmqQP+g454j6HOrOSSi3jRrhOXl51kjQ8KbAD5hkyOn3nSgzDarjfNqBiXdjKJgNaQpl4OnyHyj45Ls6r2f7fPeOD/dhPqaBbyhzrifQjGo71IkhjSi55Ogjv9nhOXl5Dbqz9obkjAmBD3p3nNnBfUqO9Ehh0XdjLIkh8Rhjz4sAn5aQqJb3rBn5fxrA9PdhPqrj9An31woAHhrBaOakTDfy9koQP7nhOXl4LDqADjkyLcfiqQc75emjvKiyrRq4GXdjLSaxbHs4bEijjhpN0TpOuFskP4iiv/dhPqn6HKs5borPnci5uPpjmPeMXKiiXOgNOXl4POg5n8eizCg65RhQLbnk5Ng2GOaliXdjL8fzDSk6LAsiSPfhb6mjuNbyLKpzqKdhPqpj0Khh1+ez5vk5vknNfOciHnk4jDa3OXl3rBkx8KmQ9dq7aShAzvnRzG/N9hjRiXdjKRjlmFg597o7flaiLCgkbwhR9mj6j/dhPqmjfvi7mKiRzopQzFoAPjaQqLnl9JgNOXl4OQjR5FeBrnclrhghzioQXLpRD2jx0XdjK=`

  • String tokenizing problem

    This suddenly started happening last night and for the life of me, i do not know why.
    when i start my applet, everything goes ok until my string tokenizer is called. Then the applet crashes and i get the following in the java console:
    java.util.NoSuchElementException
         at java.util.StringTokenizer.nextToken(Unknown Source)
         at Player.authenticateUser(Player.java:98)
         at BlackJack.connect(BlackJack.java:575)
         at BlackJack.init(BlackJack.java:182)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Now, while i understand what the error means, i don't know why it is happening. The string to be tokenized is in the form: "name: x x id: x". Here's the code that handles it:
    while(st.hasMoreTokens())
         while(!st.equals("id:"))
               if(!st.equals("name:"))
                    name += st.nextToken();
         if(st.equals("id:"))
                memID = st.nextToken();
    //Test string
    System.out.println("input:" + input+"\n");This is so annoying now as i just can't see the problem. Any ideas?

    Write down what you think the path through the code should be--how many times through the while, what happens each time, whether the if block is entered, what happens.
    Then put in a bunch of print statements so you can see the path your code is following (or use a debugger). When you see what's different between what was expected and what's actually happening, you'll be able to find your logic bug.
    Clearly something's wrong with the if and/or the while s.t. it's eating all the tokens and then still asking for more.

  • String Tokenizing/Delimeters Question

    I need to be able to delimit a string allowing the tokens within it to have theoretically any possible character that I might use to delimit. What is the best way to do that? From searches on similar topics, I'm finding possible solutions to be putting any appearances of the delimiting character in quotes or using StreamTokenizer...
    Thanks.

    Thanks Dr. Clap. Anyone know if there are any drawbacks/gotchas to using non-printable (or however you might refer to them) characters as a delimiter like below?
    See this link:
    http://www.unicode.org/charts/PDF/U0000.pdf
            StringBuffer value = new StringBuffer("this");
            value.append("\u007F");
            value.append("is");
            value.append("\u007F");
            value.append("a");
            value.append("\u007F");
            value.append("tokenized string");
            StringTokenizer st = new StringTokenizer (st.toString(), "\u007F");
            System.out.println(st.nextToken());
            System.out.println(st.nextToken());
            System.out.println(st.nextToken());
            System.out.println(st.nextToken());

  • Urgent help with string tokenizing.

    Hello Everyone,
    I'm 4 months new to Java and JSP.
    Can some one help me with a small favor please, my program below reads from a file and Tokenize the string, the top layer of the string is OK however I want to write another method to tokenize off of the top layer it must be in a separate method because I want to call the method on a JSP page. Can someone view my code and help me with the other method please.
    Thanks
    KT
    package dev;
    import java.io.*;
    import java.util.*;
    public class RoundDetail2
    public String string_gameID;
    public String string_roundID;
    public String string_bet;
    public String string_win;
    public String string_roundDetail;
    public String string_date_time;
    public String tokenizer_topLayer;
    public String readDetail_topLayer;
    public static final String SUITS[] = {" ", "Clubs", "Hearts", "Spades", "Diamonds", "Joker", "FaceDown"};
    public static final String VALUES[] = {"Joker ","Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
    public static final String SuitVALUES[] = {" ","1","2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"};
    public RoundDetail2() throws FileNotFoundException
    DataInputStream inFile=
                 new DataInputStream(
                    new BufferedInputStream(
                   new FileInputStream("C:/apps/jakarta-tomcat-4.0.6/webapps/ROOT/WEB-INF/classes/dev/Data_452SY2.txt")));
    try { 
                 if((readDetail_topLayer = inFile.readLine()) != null)
              StringTokenizer tokenizer_topLayer = new StringTokenizer(readDetail_topLayer,"\t", true);
                   if (tokenizer_topLayer.hasMoreTokens())
                        string_gameID = tokenizer_topLayer.nextToken();
                        string_roundID = tokenizer_topLayer.nextToken();                                   
         catch(IOException e)
                    System.out.println(e.getMessage());
         

    If you are trying to read tab delimited file and tokenize the contents, the code should be as below:
    package dev;
    import java.io.*;
    import java.util.*;
    public class RoundDetail2 {
         public String string_gameID;
         public String string_roundID;
         public String string_bet;
         public String string_win;
         public String string_roundDetail;
         public String string_date_time;
         public String tokenizer_topLayer;
         public String readDetail_topLayer;
         public static final String SUITS[] = {" ", "Clubs", "Hearts", "Spades", "Diamonds", "Joker", "FaceDown"};
         public static final String VALUES[] = {"Joker ","Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
         public static final String SuitVALUES[] = {" ","1","2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"};
         String gameInfoText = "";
         public RoundDetail2() throws FileNotFoundException
              DataInputStream inFile = new DataInputStream(new BufferedInputStream(
                                            new FileInputStream("C:/apps/jakarta-tomcat-4.0.6/webapps/ROOT/WEB-INF/classes/dev/Data_452SY2.txt")));
              try
                   while((readDetail_topLayer = inFile.readLine()) != null)
                        gameInfoText += readDetail_topLayer;
              }     catch(IOException e)
                   System.out.println(e.getMessage());
         public void getGameInfo()
              StringTokenizer tokenizer_topLayer = new StringTokenizer(gameInfoText,"\t", false);
              while (tokenizer_topLayer.hasMoreTokens())
                   string_gameID = tokenizer_topLayer.nextToken();
                   string_roundID = tokenizer_topLayer.nextToken();
                   System.out.println(string_gameID+" : "+string_roundID);
         public static void main(String[] args)
              try
                   RoundDetail2 roundDetail = new RoundDetail2();
                   roundDetail.getGameInfo();
              }catch(Exception e){}
    Test if it works for you by running at command prompt.
    Goodluck
    -Mak

  • How many string tokens do I have?

    String line = "00:05,  4 May 2007;
    StringTokenizer st = new StringTokenizer(line);Four or five?
    I am not sure whether ":" or "," is a default delimiter?
    Thanks

    http://java.sun.com/javase/6/docs/api/java/util/StringTokenizer.html#countTokens()
    Also, "StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code."
    ~

  • String tokenizing in pl/sql

    Hi
    I want to split a string based on certain delimiters in pl/sql
    just like stringtokenizer in java.Can anybody help me ?
    regards
    prasad

    Try this; it works for me
    create or replace function ExtractFIeld(
         InString varchar2,
         FieldPos pls_integer,
         Delim     varchar2) return varchar2 is
         NextPos          pls_integer;
         InitPos          pls_integer := 1;
         DelimLength     pls_integer;
         CutLength     pls_integer;
         N_1thDelimPos     pls_integer := 0;
         NthDelimPos     pls_integer := 0;
         ReturnField varchar2(128);
    begin
         if Delim is NULL then
              return InString;
         end if;
         DelimLength := length(Delim);
         if (FieldPos > 1) then
              N_1thDelimPos := instr(InString, Delim, 1,
    FieldPos-1);
              if (N_1thDelimPos = 0) then
                   return NULL;
              else
                   InitPos := N_1thDelimPos + DelimLength ;
              end if;
         else
              N_1thDelimPos := 0;
              InitPos      := 1;
         end if;
         NthDelimPos := instr(InString, Delim, 1, FieldPos);
         if (NthDelimPos = 0) then
              NextPos := length(InString);
         else
              NextPos := NthDelimPos - 1;
         end if;
         ReturnField := substr(InString, InitPos, NextPos -
    InitPos + 1);
         Return ReturnField;
    exception
         when others then
              ReturnField := NULL;
    end ExtractFIeld;

  • String Tokenizing Help

    I'm having problems with looking through a sentence for a word in my case the word breakfast should be found and the result should be "found" but it is doing my 'else' what am I doing wrong with the IndexOf i have been looking at this for hours on the net and its confused me, any help would be great.
    static String findWord() {
    String result = "";
    String sentence = "I like a good breakfast";
    StringTokenizer st = new StringTokenizer(sentence);
    while (st.hasMoreTokens()) {
    String temp = st.nextToken();
    if (temp.indexOf("breakfast") > 0) {
    result = "found";
    } else
    ...... code omitted ... do something else.

    yep, returns "found"
    public static string findWord() {
          String result = "not found";     
          String sentence = "I like a good breakfast";     
          if (sentence.indexOf("breakfast") >= 0)       {           
            result = "found";     
          else      
    return result;
    [\code]
    sounds like a short circuit between keyboard and ground !!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • Subpanel doesn't work in Runtime application

    I created an application that uses a Subpanel. The Subpanel works correctly when I am running the code in LabVIEW, but nothing shows up when I use the runtime application. Are subpanels handled differently by the runtime engine than they are in the F

  • Dynamic dropdown with jsp

    Hi, can someone suggest me how to implement following concept in JSP (only through jsp) i have one dropdown list box,which is holding source values, on selecting source the second dropdown list box should display destination values from database. i h

  • Water damaged iPhone - Ultrasonic cleaning?

    Hi, I have managed to kill my 16GB iPhone G3, it might be smart but unfortunately it can't swim. I have emailed a few repair companies. ipaqrepair.co.uk has offered me free diagnostic and said they can repair some water damaged units using an ultra s

  • Wast not credited my $5 deposit at preorder checkout! Please help....

    A very inexperienced cashier who didn't even know how to process video game pre-orders correctly (he had to ask someone to show him how) ended up cheating me out of my $5 deposit credit.  I hope someone here can help me get it back without a trip to

  • Problems with Overlay Layout - can anyone spot something wrong/missing?

    Hi folks, I'm developing a tool that allows you to draw rectangles around objects on an image. The rectangles are then saved, and you can move between images. For some reason, though my rectangles are not drawing on the panel. I am using the Overlay