String Tokinzer problem

Hi ,
I wanted to toknize following string using token "#,"
ABC#,A (C, D, E, F) & G#,XYZ (FGH)#, DEF(CDE)#, QPR
i.e i need
ABC
A (C, D, E, F) & G etc.........
but it also tokinzes for occurance of ,
it returns
ABC
A(C
D
Please suggest

StringTokenizer can only tokenize on single characters. Try [String.split|http://java.sun.com/javase/6/docs/api/java/lang/String.html#split(java.lang.String)] instead.
Edit:
Too slow :-(

Similar Messages

  • Setting input fields to an empty string BIG PROBLEM

    Hi Rob, thanks for your rerply, It makes sense alright, but I am using 2 seperate input fields. I have discovered what is causing the problem .
    After the user types into the inputfield and moves on to a different frame, I have set the input field to an empty string and this is what is causing the problem.
    I have tried setting the input field to an empty string in a movie script and on individual sprites and the first right answer is not excepted.I have to type in the right answer twice to get get a right response. I am actually using three seperate input fields in total, each with a different name and behavior. Even If I use one input field I still have the same problem. Its driving me crazey. Any Ideas.
    Anne

    I believe that the FIM Service always does trims on string, so you may be out of luck.
    What is your scenario / what are you trying to accomplish by setting a space in an attribute? A space is not an empty string in my definition.
    Regards, Soren Granfeldt
    blog is at http://blog.goverco.com | facebook https://www.facebook.com/TheIdentityManagementExplorer | twitter at https://twitter.com/#!/MrGranfeldt

  • String concat PROBLEM??? Please Help

    I have this strange Question regarding String concat
    If I say:
    String str = "Welcome";
    str.concat(" to Java");
    System.out.println(str);
    The output is: Welcome.
    How do I get the output to Welcome to Java??

    I have this strange Question regarding String concat
    If I say:
    String str = "Welcome";
    str.concat(" to Java");
    System.out.println(str);
    The output is: Welcome.
    How do I get the output to Welcome to Java??
    The problem is that String is immutable, The String you have held in str does not change, rather a new Srtring is returned. So all yo have to do is grab the new String
    str = str.concat("to Java");
    or use the new String without keeping it.
    ie
    System.out.println(str.concat("to Java"));

  • String concat problem

    Hi folks,-
    i know this question might be very simple but i just cannot see what i am doing wrong here.
    String stringA, stringB, stringC;
    stringA= new String();
    stringB= new String();
    stringC= new String();
    stringA = null;
    stringB = "TRUE";
    stringC = "Error:";
    stringA.concat(stringB); // my code stops and quits here w/o error
    // other codewhat is wrong here?
    thanks much

    could you then please explain the following?
    public String concat(String str)Concatenates the
    specified string to the end of this string.
    If the length of the argument string is 0, thenthis
    String object is returned. Otherwise, a new String
    object is created, representing a charactersequence
    that is the concatenation of the charactersequence
    represented by this String object and thecharacter
    sequence represented by the argument string.
    Examples:
    "cares".concat("s") returns "caress"
    "to".concat("get").concat("her") returns"together"
    Parameters:
    tr - the String that is concatenated to the end of
    this String.
    Returns:
    a string that represents the concatenation of this
    object's characters followed by the stringargument's
    characters.
    Throws:
    NullPointerException - if str is null.It returns a new String, which you are
    throwing away. Change your code like this:
    stringA = stringA.concat(stringB);
    and then you'd get somewhere.yes, it makes sense but the description does not say this.
    i think that will work but my problem is with the description of this
    concat operation on the java web site.
    thanks for the help

  • String check problem

    I have a doozy of a problem on my hands. My company has introduced a password policy that every user must me now. Some of my criteria is that a password must contain at least one symbol and at least one number. In 10g I can use REGEXP_LIKE function, but I am running 9i. I have tried to use translate, OWA_PATTERN function, everthing. How can I take a string variable, and test to see if there is a symbol in the text or a number. I want to be able to return a true/false value?
    Please advise?

    Like Kamal says, use built-in functionality FIRST.
    Failing that, presumably you would write something like this (I forget the exact naming standard for the password verify function).
    CREATE FUNCTION valid_password (
       p_password IN VARCHAR2)
       RETURN BOOLEAN
    IS
       FUNCTION contains_at_least_one (
          p_string IN VARCHAR2,
          p_characters IN VARCHAR2)
          RETURN BOOLEAN
       IS
       BEGIN
          RETURN LENGTH (TRANSLATE (p_string, 'X' ||
            p_characters, 'X')) < LENGTH (p_string);
       END;
    BEGIN
       RETURN contains_at_least_one (p_password, '0123456789')
          AND contains_at_least_one (p_password, '!£$%^&*(){}~@??|<>');
    END;

  • String overlapping problem in mx:List caused by wordWrap

    I'm using mx:List to display String items. The dataProvider is XMLListCollection. Some of the String is long so it takes more than one rows. I use the wordWrap to display the long String in more than one rows. The problem is that the next String item will overlapping with the long String. The mx:List can not adjust the vertical space for the Strings that needs more than one rows dynamically. Any suggections?

    Here is solution: variableRowHeight="true"

  • String offset problem

    Hi,
    I'm using 1.4.2 at the moment.
    I got the problem below and have no idea how to solve it. The program portion is:
    String x = node.getText();
    The node.getText() should contain value = "\n\r"
    However, it always return me "\r" only.
    I checked with the debugger and found that when I change the offset value of x to 0, it can return me "\n". However, the original offset value is always kept as 1. That's the reason why it always return me "\r".
    Can anyone help and tell me how to get the value "\n" in this case, i.e. any String method which I can check and get the offset value 0 from the string x.
    Thanks million in advance.
    Regards,
    Eric

    Can anyone help and tell me how to get the value "\n"
    in this case, i.e. any String method which I can
    check and get the offset value 0 from the string x.
    x.charAt(0);is probably what you mean.

  • String item problem

    I use mobility pack visual designer.
    When I create a string item in visual screen designer it looks like that:
    Title
    <text>
    but after i run my app it looks different
    Title <text>
    Why there's no line break?
    When I try to add the line break manually it doesn�t work because screen designer property editor adds to the code \\n when I put \n
    so generated code looks like that
    stringItem1 = new StringItem("stringItem1\\n", "<Enter Text>");  and I cannot edit it manually because generated code is blocked by net beans
    I can initialize my stringItem object one again
    stringItem2 = new StringItem("stringItem2\n", "<Enter Text>");  but I thing that�s very stupid to reinitialize an object twice
    And the line break after title doesn't solve my problem because if the title is too long the device will automatically brake the line and I�ll get this
    A long long title........
    <text>
    one empty line because of that break
    Any ideas?
    I don�t want to use textField because when you set it to uneditable its color becomes gray.

    Check the actual URL up in the location bar. Your comma may actually be dropping out there, because it isn't encoded such that in value commas can be differentiated from delimiters, so the fields aren't lining up in the URL properly.
    When you go to a page that takes in parameters for assignment in the link, it has 2 fields. The first is the comma separated list of the item names on the page to assign, which wouldn't contain commas in their names. The other field in the URL is a comma separated list of values to be assigned to the previous list. Since these values aren't encoded, the comma in the value is picked up as delimiter and not a part of the value. I have an example I can load up to apex.oracle.com if you need.
    -Richard
    Edited by: rwendel on Aug 13, 2009 11:51 AM

  • Passing string data problem

    Dear readers,
    I came across some problem in my labview VI where I try to pass a string (stored in a local variable) to other string variables connected to that local variable. In this case, I have a local string variable called 'output_string1', which contains the string '123'. I have it set to 'write'. Then I connect 3 string Indicators to this local variable, called 'string1', 'string2', and 'string3'. I would expect these connected string indicators to also contain the string '123', as they're simply connected to the 'output_string1'. But the strange thing is that only 'string2', and 'string3' contains '123', but 'string1' contains a '.' (ie a dot). Would someone be able to provide some kind advice about what I might be doing wro
    ng to get this result? I've attached the vi that I was making that demonstrates what I described. Thank you very much for your help.
    Attachments:
    remove_trailing_zeros_subvi.vi ‏78 KB

    In the last sequence you have intended to concatinate a string from three inputs; the local variable before, a "." and a local of string1. BUT instead of reading the local of string1 you have it in write mode...and the "." is wired into it! So you really wire 123 to that indicator as well in sequence 5, but it is immediately overwritten by a "." in the next sequence.
    That aside though there's two other things about the code that needs to be commented:
    a) You use locals as you would use them if G was a textual language; like variables. In G though we try to avoid locals all together, in G the wire is the variable! The wire in addition ensures the next thing the code lacks; execution control.
    b) Instead of sequences, use data flow. By working
    with the wire instead of locals you can ensure that things execute in the order you want it to, without the need for a sequence structure. And without a sequence structure the code becomes much easier to read and maintain.
    I have attached a modified version of your code that applies these two conversions to a "G" way of programming.
    Removing trailing zeroes can be done much easier though, attached is also an example of one such way.
    MTO
    Attachments:
    remove_trailing_zeros_Simplified.vi ‏45 KB
    remove_trailing_zeros_improved.vi ‏22 KB

  • String compare problem

    I try to compare 2 strings with compareTo/equalTo, but it's not working, those 2 funcs always return ture.
    public boolean chMark(String name, String test, String newMark)
              boolean flag = false;
              for(int i = 0; i < course.getNumOfStd(); i++)
                   if(course.getStd().getName().compareTo(name)==0)//here is problem;
                        Student tempStd = course.getStd()[i];
                        for(int j = 0; j < tempStd.getMark().getNumOfTests(); j++)
                        if(tempStd.getMark().getTestArray()[j].getTitle().compareTo(test)==0);//here is problem;
                             int mark = Integer.parseInt(newMark);                    }
              return flag;
    Can anybody tell me why?
    REGARDS,
    Elton

    equals() would read more naturally than compareTo()==0. But, in
    either case, use System.out.println() to write the two strings before
    you compare them. This is to check that you are comparing what
    you think you're comparing.System.out.println("name from course is " + course.getStd().getName());
    System.out.println("name is " + name);
    if(course.getStd()[i].getName().compareTo(name)==0)//here is problem;
    System.out.println("name from couse and name compared equal");
    // etc

  • Javabean string invoking problem

    I have two JSPs, one takes a request and the other displays the result and I am having problem with the javabean to connect the two
    here are my codes
    takes request
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>
    <table border="1" align="center">
    <tr>
    <td colspan="3" bgcolor="black" align="center"><font color="orange" size="3">
    Computer Voting Poll</font></td></tr>
    <tr>
    <td colspan="3" bgcolor="black" align="center"><font color="orange" size="3">
    What is your favorite computer game?
    </font></td></tr>
    <tr><td width="20%" bgcolor="black"></td>
    <td width="30%" bgcolor="black" align="left">
    <FORM ACTION="PollResult.jsp">
    <input type="radio" name="firstChoice" value="Oblivion" checked><font color="orange" size="2"> Oblivion </font><br>
    <input type="radio" name="secondChoice" value="starwars"><font color="orange" size="2"> Star Wars: Empire at War </font><br>
    <input type="radio" name="thirdChoice" value="finalfantasy"><font color="orange" size="2"> Final Fantasy XI: Online </font><br>
    <input type="submit" value="vote button" name="Vote">
    </td>
    <td bgcolor="black" width="20%"></td>
    </tr>
    <tr><td bgcolor="black" colspan="3" align="center"><font color="orange" size="3">
    </font><font color="white" size="3">Total Votes</font></td></tr>
    <tr><td height="15" bgcolor="orange" colspan="3"></td></tr>
    <tr><td align="left" bgcolor="black"><font color="white" size="3">0</font></td>
    <td align="left" bgcolor="black"><font color="white" size="3">Oblivion</font></td>
    <td align="center" bgcolor="black"><font color="white" size="3">0.00%</font></td>
    </tr>
    <tr><td align="left" bgcolor="black"><font color="white" size="3">0</font></td>
    <td align="left" bgcolor="black"><font color="white" size="3">Star Wars: Empire at War</font></td>
    <td align="center" bgcolor="black"><font color="white" size="3">0.00%</font></td>
    </tr>
    <tr><td align="left" bgcolor="black"><font color="white" size="3">0</font></td>
    <td align="left" bgcolor="black"><font color="white" size="3">Final Fantasy XI: Online</font></td>
    <td align="center" bgcolor="black"><font color="white" size="3">0.00%</font></td>
    </tr>
    <tr><td height="15" bgcolor="orange" colspan="3"></td></tr>
    </table>
    </body>
    </html>displays
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>
    <table border="1" align="center">
    <tr>
    <td colspan="3" bgcolor="black" align="center"><font color="orange" size="3">
    Computer Voting Poll</font></td></tr>
    <tr>
    <td colspan="3" bgcolor="black" align="center"><font color="orange" size="3">
    What is your favorite computer game?
    </font></td></tr>
    <tr><td width="20%" bgcolor="black"></td>
    <td width="30%" bgcolor="black" align="left">
    <input type="radio" name="firstChoice" value="Oblivion" checked><font color="orange" size="2"> Oblivion </font><br>
    <input type="radio" name="secondChoice" value="starwars"><font color="orange" size="2"> Star Wars: Empire at War </font><br>
    <input type="radio" name="thirdChoice" value="finalfantasy"><font color="orange" size="2"> Final Fantasy XI: Online </font><br>
    <input type="submit" value="vote button" name="Vote">
    </td>
    <td bgcolor="black" width="20%"></td>
    </tr>
      <TR><TH>
          Using jsp:setProperty</TABLE>
    <jsp:useBean id="entry" class="core.BeanPoll" />
    <jsp:setProperty
        name="entry"
        property="firstChoice"
        param="firstChoice" />
    <jsp:setProperty
        name="entry"
        property="secondChoice"
        param="secondChoice" />
    <jsp:setProperty
        name="entry"
        property="thirdChoice"
        param="thirdChoice" />
    <BR>
    <tr><td bgcolor="black" colspan="3" align="center"><font color="orange" size="3">
    </font><font color="white" size="3">Total Votes</font></td></tr>
    <tr><td height="15" bgcolor="orange" colspan="3"></td></tr>
    <tr><td align="left" bgcolor="black"><font color="white" size="3">0</font></td>
    <td align="left" bgcolor="black"><font color="white" size="3">Oblivion</font></td>
    <td align="center" bgcolor="black"><font color="white" size="3"><jsp:getProperty name="entry" property="firstChoice" />%</font></td>
    </tr>
    <tr><td align="left" bgcolor="black"><font color="white" size="3">0</font></td>
    <td align="left" bgcolor="black"><font color="white" size="3">Star Wars: Empire at War</font></td>
    <td align="center" bgcolor="black"><font color="white" size="3"><jsp:getProperty name="entry" property="secondChoice" />0.00%</font></td>
    </tr>
    <tr><td align="left" bgcolor="black"><font color="white" size="3">0</font></td>
    <td align="left" bgcolor="black"><font color="white" size="3"><jsp:getProperty name="entry" property="thirdChoice" />Final Fantasy XI: Online</font></td>
    <td align="center" bgcolor="black"><font color="white" size="3">0.00%</font></td>
    </tr>
    <tr><td height="15" bgcolor="orange" colspan="3"></td></tr>
    </table>
    </body>
    </html>javabean
    * BeanPoll.java
    * Created on October 29, 2007, 11:18 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package core;
    /** Simple bean to illustrate the various forms
    *  of jsp:setProperty.
    *  <P>
    *  Taken from Core Servlets and JavaServer Pages 2nd Edition
    *  from Prentice Hall and Sun Microsystems Press,
    *  http://www.coreservlets.com/.
    *  &copy; 2003 Marty Hall; may be freely used or adapted.
    public class BeanPoll {
      private String firstChoice = "unknown";
      private String secondChoice = "unknown";
      private String thirdChoice = "unknown";
      public String getfirstChoice() {
        return(firstChoice);
      public void setfirstChoice(String firstChoice) {
        if (firstChoice != null) {
          this.firstChoice = firstChoice;
        } else {
          this.firstChoice = "unknown";
      public String getsecondChoice() {
        return(secondChoice);
      public void setsecondChoice(String secondChoice) {
        if (secondChoice !=null) {
            this.secondChoice = secondChoice;
        } else {
            this.secondChoice = "unknown";
      public String setthirdChoice() {
        return(thirdChoice);
      public void setthirdChoice(String thirdChoice) {
        if (thirdChoice !=null) {
            this.thirdChoice = thirdChoice;
        } else {
            this.thirdChoice = "unknown";
      // In real life, replace this with database lookup.
      // See Chapters 17 and 18 for info on accessing databases
      // from servlets and JSP pages.
      public double getPollResult() {
        double result;
      public double getTotalCost() {
        return(getItemCost() * getNumItems());
    }thanks for your time

    You have a getter method whose name starts with "set".
    You're not following the beans naming conventions correctly. If a property is called "foo", then the getters & setters are named "getFoo" and "setFoo".

  • Struts String Array problem:

    Hello All,
    I'm working on a DynaValidatorForm in struts and I'm not able to define my string arrays without compile errors in WSAD 5.0 and it doesn't work right with the validator for those two items. WSAD 5.0 uses a 1.3 beta version of struts and that may be the problem or it may be a bug in the validator. Not sure which. This is what I have in the struts-config.xml file for the form-bean:
    <form-beans>
    <form-bean name="submitDynaValidateForm"
    type="org.apache.struts.validator.DynaValidatorForm">
    <form-property name="lastName"     type="java.lang.String"/>
    <form-property name="address"      type="java.lang.String"/>
    <form-property name="sex"      type="java.lang.String"/>
    <form-property name="married"      type="java.lang.String"/>
    <form-property name="children"      type="java.lang.String[]"/>
    <form-property name="age"      type="java.lang.String"/>
    <form-property name="interests" type="java.lang.String[]"/>
    </form-bean>
    </form-beans>
    Anyone come across this problem before and do you know how to solve it other than doing the validation for the String Arrays in the Action class?
    Thanks,
    James

    I don't know how to solve it, but I'd wonder about the need to validate the array of Strings. I think that should just be a String type.
    If you have String arrays to populate a drop-down list, I think the assumption has to be that the drop-down has been populated properly. There's no need to re-check it every time. Even if the list is changing, because its contents are driven by another selection, the responsibility for getting those values correct lie outside the validator's domain.
    And since the single selection that's actually sent as input comes from an array of valid values, there's no opportunity for the user to send an invalid value.
    I think the validation framework is for checking manual, typed user input to make sure they're the correct types, no typo errors, etc.
    Business validity is another matter that the Struts validation framework shouldn't address. Those business rules belong on the middle tier, IMO.

  • Help:String arg[ ] problems

    Hi:
    I am having problems with my encryption program and I want to check that the contents at the command line a being read properly.
    ex: java Monoalphabet -k feather in.txt out.txt
    -k(indicates encryption)
    feather(keyword)
    How do I check to make sure that the input in being read into String args[]properly?
    Thanks.

    Print the args out using System.out.println() in a loop at the beginning of your main method.

  • Strings comparison problem (wap application), please try to help me!!

    hello buddies!!
    Well , I'm having a problem in my WAP application.
    My wap application is very simple and consist a
    authentication of a form (name and password). That is, geting the
    the enties from the form and compare with the data from
    the database. The problem is: when i compare
    the String from the form with the String from the
    database the result is always the same "false". I have displayed
    the database and form string on the next card and
    they are ,indeed, the same, so i don't know what's happening.
    why the method
    public boolean matchName(String name){
        if(name == databaseName)
            return true;
        return false;
    }is always returning false even though on the next card
    with :
    out.write("<p>name = "+name+"</br>databaseName = "+databaseName)it displays :
        name = Marcos
        databaseName = Marcos I have maden tests with the connection, i can display a list from
    the same database, that is the only problem So, if you have any
    suggestion, please let me know, thanks very much!!

    hi :-)
    try this:
    if(name.equals(databaseName))regards,

  • 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

  • Smart List Data not getting copied

    Hi, I am working on workforce model. I am trying to copy data from new employee (example: TBH1) to another employee XYZ (TBH1 & XYZ are in employee dimension). The intersection where I am entering data for TBH1 is: Account -> New Hires Currecny -> Lo

  • Webutil in forms6i

    I realize webutil is not supported for forms 6i. However, we are not planning on using forms 9i/10g soon and would like to use webutil if possible. My question is, has anyone successfully used webutil with forms 6i / (should I spend time trying to ge

  • Positions - TIME CONSTRAINT ISSUE

    Dear Colleagues, I am not able to assign one  position to more then one employee. Even changed the TC to 3 for relationship 008. Please help. Regards, Garima

  • Mitsubishi WD-73740 smart dlp hdtv internet questions.

    i'm intersted in upgrading to the mitsubishi WD-73740 hdtv smart internet ready set but from past experience with my mitsubishi WD-65638 non-internet ready dlp hdtv running an hdmi cable from my laptop to my tv's hdmi input gives me a horrible pictur

  • My safari keeps crashing after one minute + microsoft word won't open

    Hey, I'm having some trouble with my safari crashing very soon after it opens every single time I open it. I'm not very mac-savvy so i'm not sure what the problem could be. After a while my microsoft word stopped opening, is this related? The Word th