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(",")                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

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 :)

  • 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.

  • 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());

  • 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.

  • Very simple XSLT string replacing question

    Hi,
    This is a really simple question for you guys, but it took me long, and i still couldn't solve it.
    I just want to remove all spaces from a node inside an XML file.
    XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <root insertedtime="2008-05-01T14:03:00.000+10:00" pkid="23421">
       <books>
          <book type='fiction'>
             <author>John Smith</author>
             <title>Book title</title>
             <year>2 0  0 8</year>
          </book>
       </books>
    </root>in the 'year' node, the value should not contain any spaces, that's the reason why i need to remove spaces using XSLT. Apart from removing space, i also need to make sure that the 'year' node has a non-empty value. Here's the XSLT:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:strip-space elements="*"/>
        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
        </xsl:template>
        <xsl:template match="//books/book[@type='fiction']">
            <xsl:copy>
                <xsl:apply-templates select="@*"/>
                <xsl:attribute name="id">101</xsl:attribute>
                <xsl:call-template name="emptyCheck">
                    <xsl:with-param name="val" select="year"/>
                    <xsl:with-param name="type" select="@type"/>
                    <xsl:with-param name="copy" select="'true'"/>
                </xsl:call-template>
                <xsl:value-of select="translate(year, ' ', '')"/>
            </xsl:copy>
        </xsl:template>
        <!-- emptyCheck checks if a string is an empty string -->
        <xsl:template name="emptyCheck">
            <xsl:param name="val"/>
            <xsl:param name="type"/>
            <xsl:param name="copy"/>
            <xsl:if test="boolean($copy)">
                <xsl:apply-templates select="node()"/>
            </xsl:if>
            <xsl:if test="string-length($val) = 0 ">
                <exception description="Type {$type} value cannot be empty"/>
            </xsl:if>
        </xsl:template>
    </xsl:stylesheet>The 'emptyCheck' function works fine, but the space replacing is not working, this is the result after the transform:
    <?xml version="1.0" encoding="utf-8"?>
    <root insertedtime="2008-05-01T14:03:00.000+10:00" pkid="23421">
       <books>
          <book type="fiction" id="101">
             <author>John Smith</author>
             <title>Book title</title>
             <year>2 0 0 8</year>2008</book>
       </books>
    </root>The spaced year value is still there, the no-space year is added outside the 'year' tags'
    anyone can help me, your help is extremely appreciated!
    Thanks!

    You should add a template for 'year' :<xsl:template match="year">
    <year><xsl:value-of select="translate(.,' ','')"/></year>
    </xsl:template>and remove the translate call in the 'book' template.
    It would be better to add a 'priority' attribute at each template so it would be explicit which template to use because match="@*|node()" could be interpreted by another transform engine as the unique template to be used !

  • 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);
    }

  • How do I view previous strings of questions and answers on FF support?

    I read this response but it really doesn't answer the question.
    "If you are logged on then you see a My Contributions item in the Filter bar at the top that goes to:
    https://support.mozilla.org/questions?filter=my-contributions"
    I don't see the "filter bar" or "my responses" after I log in. I just see "Ask a question" "my log in name" and some other stuff to the right of that and below that.
    So after I log in, how do I look at strings of my previous questions and all responses to them, including new ones?

    I just figured it out!!! Wha-lah. Go to a question and then click on the underlined text in the question. Then a string of the Q and subsequent responses appears.

  • Username/password token question... wss4j

    I have an axis webservice which requires client to send username/password tokens for authentication. my server
    does the "authentication" with no problem (match client's username and password with server's password).
    I have many users (that means many clients with different usernames and passwords) when the user calls
    one of my allowed methods I want to know which user called that method.
    I would appreciate if you help me finding out which "client"(user) is calling the allowed method.
    I use wss4j to process username/password tokens.
    In my wssd file I have following to show where my password checking will take place:
          <requestFlow>
            <handler type="java:org.apache.ws.axis.security.WSDoAllReceiver">
              <parameter name="passwordCallbackClass" value="com.alex.ws.callback.PWCallback"/>
              <parameter name="action" value="Timestamp UsernameToken"/>
            </handler>
          </requestFlow>In my Callnack class com.alex.ws.callback.PWCallback I have:
        public void handle(Callback[] callbacks)
                throws IOException, UnsupportedCallbackException {
            for (int i = 0; i < callbacks.length; i++) {
              System.out.println("1");
                if (callbacks[i] instanceof WSPasswordCallback) {
                    WSPasswordCallback pc = (WSPasswordCallback) callbacks;
    if (pc.getUsage() == WSPasswordCallback.KEY_NAME) {
    pc.setKey(key);
    } else {
    pc.setPassword(UserStore.getPassword(pc.getIdentifer()));
    } else {
    throw new UnsupportedCallbackException(callbacks[i],
    "Unrecognized Callback");
    When the user sends SOAP message with Username/Password token
    PWCallback class works fine and authentication is done with no problem.
    One of my allowed method is :
    public String doIt(String msg)
       System.out.println("Here is the message:"+msg);
      String username= "";
    //some code to find the username
    //of the sender. Please help me in here
       System.out.println("Here is the username that sent the msg:"+username);
    }Can you help me to find out how I can find out the "username" of client within the allowed method.

    While reading the API docs for WSS4j, I came across the section called "Reporting Security results to services/applications" in the summary for org.apache.ws.axis.security package.
    link: http://ws.apache.org/wss4j/apidocs/org/apache/ws/axis/security/package-summary.html (almost bottom of page)
    There is some example code of how to access the security result data from the server side WS implementation code. Here's the example code in case you miss it:
        public void ping(javax.xml.rpc.holders.StringHolder text,
            org.apache.ws.axis.oasis.ping.TicketType ticket)
            throws java.rmi.RemoteException {
            text.value = "Echo " + text.value.trim();
            // get the message context first
            MessageContext msgContext = MessageContext.getCurrentContext();
            Message reqMsg = msgContext.getRequestMessage();
            Vector results = null;
            // get the result Vector from the property
            if ((results =
                (Vector) msgContext.getProperty(WSHandlerConstants.RECV_RESULTS))
                 == null) {
                System.out.println("No security results!!");
            System.out.println("Number of results: " + results.size());
            for (int i = 0; i < results.size(); i++) {
                WSHandlerResult hResult = (WSHandlerResult)results.get(i);
                String actor = hResult.getActor();
                Vector hResults = hResult.getResults();
                for (int j = 0; j < hResults.size(); j++) {
                       WSSecurityEngineResult eResult = (WSSecurityEngineResult) hResults.get(j);
                    // Note: an encryption action does not have an associated principal
                     // only Signature and UsernameToken actions return a principal
                    if (eResult.getAction() != WSConstants.ENCR) {
                        System.out.println(eResult.getPrincipal().getName());
        }

  • 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

  • String tokenizer question

    I need to parse strings of the form "token A ops token B" where ops can be <, >, =, != and output "tokenA ops tokenB"....(remove spaces in the tokens).
    I can use all the ops as delimiters (though I cant specify '!='), and get the tokens and remove the spaces in them. Using StringTokenizer, I doubt if I can know the exact delimiter I encountered so that I can rebuild the string quickly. Sure, I can do an indexOf() for each of the ops to find the one used in original string. But I am curious to know if there is any better approach to do this (doesnt have to be string tokenizer approach)?

    If the tokens always consist of "word characters" (letters, digits, and underscores) and the operators always consist of punctuation characters, you can do this:   str = str.replaceAll("\\b\\s+\\b", "");

  • Classes and subclasses given as String input - question

    Hello, I am new in Java so please don't laugh at my question!!
    I have a method as the following and I am trying to store objects of the type Turtle in a vector. However the objects can also be of Turtle subclasses: ContinuousTurtle, WrappingTurtle and ReflectingTurtle. The exact class is determined by the String cls which is input by the user.
    My question is, how can I use cls in a form that I don't have to use if-else statements for all 4 cases? (Imagine if I had 30 subclasses).
    I have tried these two and similar methods so far but they return an error and Eclipse is not of much help in this case.
    Simplified methods:
    //pre:  cls matches exactly the name of a valid Turtle class/subclass
    //post: returns vector with a new turtle of type cls added to the end
    private Vector<Turtle> newturtle(Vector<Turtle> storage, String cls){
         Turtle t = new cls(...);
         storage.add(t);
         etc.
    private Vector<Turtle> newturtle(Vector<Turtle> storage, String cls){
         Turtle t = new Turtle<cls>(...);
         storage.add(t);
         etc.
    }Thanks for your help.
    p.s.: I didn't know whether to post this question here or under Generics.

    a Factory is atually very simple (100x simpler than reflection).
    example:
    class TurtleFactory
      public Turtle makeTurtle(String typeOfTurtle)
        if (typeOfTurtle.equals("lazy") { return new LazyTurtle(); }
        else if (typeOfTurtle.equals("fast") { return new FastTurtle(); }
        <etc>
    }While at first this doesn't look any better than your original problem, what we've done is made a class that is responsible for all the types of turtles. This will also benefit in case some turtles need initialization or need something passed to their constructor. You encapsulate all that knowledge in one place so you rcode doesn't become littered with it else ladders.

  • 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.

Maybe you are looking for

  • Vendor & Customer Balance On Profit Center Group

    Hi experts, I have a client Requirement. They need to display Vendor & Customer On Profit Center Group Level. Also Customer & Vendor Balance On  Same Level. Is it possible in classic G/l or i have to implement new g/l? any report program or t-code fo

  • Table Centering

    How to I center the table? I put in this line into the table area <table style="margin: auto;" However the table leans towards the right. If I can get the table to fall evenly below the navigation bar that would help.  The lines in the table header c

  • Resetting X6 to 'out of the box' state?

    By 'out of the box' state i mean both phone memory and the mass memory wiped clean, and every 3rd party app which i installed gone. How do i do it? Any help will be appreciated.. Thanks.. Nokia X6 32Gb (comes with music) Solved! Go to Solution.

  • Script format question: Title over

    Question: In the script format when using a "TITLE OVER" is it a General, Shot or an Action format. Appreciate any input here, thanks. Rich

  • Shared Photo Stream Option Missing

    I just downloaded iOS6 on my iPhone 4 (not 4S).  In settings->photos & camera THERE IS NO OPTION FOR ENABLING SHARED PHOTO STREAMS.  There is only the standard option (which is "ON") for enabling "My Photo Stream". Is this feature limited to the 4S?