How to prevent the String Tokenizer filter more than one character

I am wrinting a simple program to cut the long string into small piece of data with the delimiters "#####" by using StringTokenizer
For example:
String output ="Apple Company #####APPLECOMPANY48877 #####2005-01-01 #####TESTING1 ##### ##### ##### ##### #####MR.Apple Wong #####[email protected] #####0-852-34183741 #####0-852- #####XYZ #####Apple in the tree road #####ROOM 3T099, LEVEL 9, All WIN BLDC ##### ##### #####NT #####34KJFG45 |||||0.0000 |||||1 |||||3 |||||3";
StringTokenizer st = new StringTokenizer(output,"#####");
int i=0;
while(st.hasMoreTokens()){
System.out.println("The number is: " i" "+st.nextToken());
i++;
The result is
The number is: 0 Apple Company
The number is: 1 APPLECOMPANY48877
The number is: 2 2005-01-01
The number is: 3 TESTING1
The number is: 4
The number is: 5
The number is: 6
The number is: 7
The number is: 8 MR.Apple Wong
The number is: 9 [email protected]
The number is: 10 0-852-34183741
The number is: 11 0-852-
The number is: 12 XYZ
The number is: 13 Apple in the tree road
The number is: 14 ROOM 3T099, LEVEL 9, All WIN BLDC
The number is: 15
The number is: 16
The number is: 17 NT
The number is: 18 34KJFG45 |||||0.0000 |||||1 |||||3 |||||3----->
It is correct!!!!!!
But, if the one of the small string in the long string contain the character "#", I found the "#####" and "#" also trace as delimiters by StringTokenizers to filter the String such as following example:
I only add one more "#" in String "ROOM 3T099, LEVEL 9," from the above example:
String output ="Apple Company #####APPLECOMPANY48877 #####2005-01-01 #####TESTING1 ##### ##### ##### ##### #####MR.Apple Wong #####[email protected] #####0-852-34183741 #####0-852- #####XYZ #####Apple in the tree road #####ROOM #3T099, LEVEL 9, All WIN BLDC ##### ##### #####NT #####34KJFG45 |||||0.0000 |||||1 |||||3 |||||3";
StringTokenizer st = new StringTokenizer(output,"#####");
int i=0;
while(st.hasMoreTokens()){
System.out.println("The number is: " i" "+st.nextToken());
i++;
But the result is:
The number is: 0 Apple Company
The number is: 1 APPLECOMPANY48877
The number is: 2 2005-01-01
The number is: 3 TESTING1
The number is: 4
The number is: 5
The number is: 6
The number is: 7
The number is: 8 MR.Apple Wong
The number is: 9 [email protected]
The number is: 10 0-852-34183741
The number is: 11 0-852-
The number is: 12 XYZ
The number is: 13 Apple in the tree road
The number is: 14 ROOM
The number is: 15 3T099, LEVEL 9, All WIN BLDC
The number is: 16
The number is: 17
The number is: 18 NT
The number is: 19 34KJFG45 |||||0.0000 |||||1 |||||3 |||||3
I have found that the StringTokenizer trace "#####" and "#" to be delimiters to filter the String, I only want to filter the String by StringTokenizer with "#####" not include "#"
So What Can I Do? Is it
StringTokenizer st = new StringTokenizer(output,"#####");
not Correct?
It is thank a lot if anyone can help me! thx!!

If I must use StringTokenizer, How can I do it? You completely misunderstand how StringTokenizer works.
StringTokenizer st = new StringTokenizer(output,"#####");Each character is used as a delimiter. So you have specified the same delimiter 5 times.
As suggested above you would need to rewrite the entire code, to treat the String as a delimiter, intead of each character as a delimiter.

Similar Messages

  • How to prevent the User from loading more than one seq file?

    Hi,
    I would like to prevent the tester operator from loading more than one test sequence.  Any ideas how to do it?
    Thanks
    Rafi

    Hi Marty,
    Marty_H wrote:
    Hello mhousel,
    Testexec.exe by default loads the sequence files that were last open when it runs.  It is often desired behavior to have multiple sequence files load automatically. 
    [Mark Housel] Maybe for some but certainly not for me. 
    This should be easily handled by TestStand without any problems.  What do you mean by "chaos ensues"? 
    Certainly Teststand doesn't care a bit how many sequences are open.  But, when my sequences open they initialize HW of the ATE associated with
    that sequence file during the sequenceFileLoad callback.  e.g. I allocate TELNET handles to a terminal
    server that connects to multiple console within the system and als for
    the UUT.
    If a second sequence opens it knows nothing about the other sequence and again tries to open a TELENT session to the same port of the
    terminal server and obviously fails, so my sequence reports that it
    can't properly initialize the ATE HW.  Bad juju!
    Are your sequence files set to run automatically when they are loaded?
    I guess so.  Other than the trick of logging in as the special noExecution user and having special code in my sequence and modified Process Model I have no idea how to prevent a sequence fronm "runnin" when opened.
    If you want to prevent Testexec.exe from loading multiple files, you should be able to close out one of the open files when it loads and that sequence file should not load in the future.  I hope that helps.
    The trick I read somewhere else of modifying the Testexec.uir file to never re-load a sequence file automatically seemes to have covered up solved the problem.
    Thanks,
    Mark

  • How to implement the patch for maintaining more than one cookie with http?

    HI all,
    I have seen the patch for CommonsHTTPSender.java and HTTPSender.java in
    http://issues.apache.org/jira/browse/AXIS-895?page=comments#action_63350 , but I don't know how can I implement the patch. Could anyone suggest me how to do it please. Thank you in advance.

    If I must use StringTokenizer, How can I do it? You completely misunderstand how StringTokenizer works.
    StringTokenizer st = new StringTokenizer(output,"#####");Each character is used as a delimiter. So you have specified the same delimiter 5 times.
    As suggested above you would need to rewrite the entire code, to treat the String as a delimiter, intead of each character as a delimiter.

  • How to find the serial number for more than one Ipod Touch in Itunes?

    I lost my Ipod Touch (first one I bought), how can I find the serial number in Itunes or somewhere else beside I sync my daughter's new Ipod (2nd I bought) with my Itunes account, because when I try to find the serial number they show me only my daughters Ipod, not my Ipod????

    Hover the mouse pointer over your iPod backup in iTunes>Preferences>Devices and the SN will pop up.
    Go to:
    My Support Profile

  • How to use the stock locators for more than one subinventory

    Hi,
    We are working in Oracle Applications 11i.
    We have 4 different inventory organizations. Each with one main subinventory. One of those inventory organizations MWN has a subinventory defined with stock locators. The other three have their subinventories not defined with stock locators.
    Now, correct me if I'm wrong please, I cannot define a stock locator for an existing subinventory while there are onhand items in that subinventory.
    So, We will define new subinventory(for each inv org) with stock locators and then do a subinventory transfer to the new relevant new subinventory organization.
    The next point is: the user requests to use the same stock locators for the 4 inventory organizations. is this possible?
    thank you...

    We had the same issue recently.
    Users wanted same locator in the same org under different subinventories.
    We suggested 2 solutions
    1) Make the 1st locator segment=subinventory name (e.g. East.A.3.10, West.A.3.10)
    2) Add a character to the first locator (e.g. EA.3.10, WA.3.10)
    They picked up the 2nd option.
    Hope this helps
    Sandeep Gandhi
    Omkar Technologies Inc.
    Independent Techno-functional Consultant
    513-325-9026

  • How Do I Share My Database Between More Than One User Account on the Same Mac?

    How Do I Share My Database Between More Than One User Account on the Same Mac?

    How to use multiple iPhone, iPad, or iPod devices with one computer. The only way is for you to have a separate user account to log into on that computer.

  • How to restrict the delivery quantity not more than target quantity?

    Dear Gurus,
    How to restrict the delivery quantity not more than target quantity in a scheduling agreement? I think there are 2 methods.
    1. I found that setting 0 in Overdelivery Tolerance Limit in Info Record is not effective. Why?
    2. I want to set E for the message but can't find the place. The message is generated when entering and saving quantity as delivery quantity that is larger than target quantity. How can I set E to a message (067, as I remember)
    Any other effective method? Please advice. Thanks.
    Regards,
    David

    Dear all,
    It is not OK after checking everywhere you mentioned. I tested in 2 clients. In the development enviroment client, it works whatever E or W. In test enviroment, it does not work (meassge is W).
    I think there must be somewhere besides of those you menetioned.
    I notes that SAP help for the overdelivery tollerance setting of scheduling agreement: 
    Overdelivery Tolerance Limit
    Percentage (based on the order quantity) up to which an overdelivery of this item will be accepted.
    Dependencies
    If you have set the indicator in the Partial delivery/Item field to 'D' (partial delivery allowed), this takes priority. It makes no sense to define a tolerance limit for overdelivery in such case.
    Where can I see: 'the indicator in the Partial delivery/Item field to 'D' (partial delivery allowed)'? I want to check it.
    Pls help! Thanks.
    Regards,
    David

  • How to keep the Recent Call Record more than a week?

    How to keep the Recent Call Record more than a week? I found the iPhone only can keep the Recent Call Record for only a week.

    I have to disagree with your response with respect. My i phone is limiting me to call going back only 7 days ie today is 29 July and my call log will only go back to 22 July. I have only 40 calls logged for that period. I cannot view up to the 100 you mention. I have included all calls for a single caller as well ie one caller shows 7 so ive counted that as 7 calls. There appears no way to set up to 100 in the settings
    Thanks
    Graham

  • How can I sort a table using more than one column in Numbers or in Pages?

    How can I sort a table using more than one column in Numbers or in Pages?

    Hi Ron,
    On the right side of the Toolbar click the Sort and Filter button, then select Sort.
    You can then set up a multiple column sort.
    Click Add A Column, Specify the sort for that column, Repeat.
    Jerry

  • The "Measures" dimension contains more than one hierarchy... Collation issue

    It appears that an Excel query pased through to SSAS has a "measures" with lowercase "m" when analysis services expects an uppercase "M" so it should look like "Measures". Is there a fix in excel to allow
    the correct passing of "Measures" member name to the cube?
    BTW, I have NO Calculations in the cube.
    In excel 2013 when I pivot with a pivot table connected to a case sensitive collation (non default config)
    cube and perform a filter by "Keep only Selected Items" I get the error "The 'Measures' dimension contains more than one hierarchy, therefore the hierarchy must be explicity specified".
    When I revert back to server wide setting to case insensitive, and I preform the exact same pivoting function it works without error. The problem appears to be that excel does not understand the server collation setting.
    When I run SQL Server Profilier I narrowed down the MDX statement run in Excel that gives me an error to this:
    with
    member measures.__XlItemPath as
    Generate(
    Ascendants([Employee].[Location Code].currentmember),
    [Employee].[Location Code].currentmember.unique_name,
    "|__XLPATHSEP__|"
    member measures.__XlSiblingCount as
    Generate(
    Ascendants([Employee].[Location Code].currentmember),
    AddCalculatedMembers([Employee].[Location Code].currentmember.siblings).count,
    "|__XLPATHSEP__|"
    member measures.__XlChildCount as
    AddCalculatedMembers([Employee].[Location Code].currentmember.children).count
    select { measures.__XlItemPath, measures.__XlSiblingCount, measures.__XlChildCount } on columns,
    [Employee].[Location Code].&[01W]
    dimension properties MEMBER_TYPE
    on rows
    from [Metrics]
    cell properties value
    Playing around with the query I discovered that if I capitalize the first letter of the "with measures" member, the statement works.
    with
    member Measures.__XlItemPath as
    Generate(
    Ascendants([Employee].[Location Code].currentmember),
    [Employee].[Location Code].currentmember.unique_name,
    "|__XLPATHSEP__|"
    member Measures.__XlSiblingCount as
    Generate(
    Ascendants([Employee].[Location Code].currentmember),
    AddCalculatedMembers([Employee].[Location Code].currentmember.siblings).count,
    "|__XLPATHSEP__|"
    member Measures.__XlChildCount as
    AddCalculatedMembers([Employee].[Location Code].currentmember.children).count
    select { measures.__XlItemPath, measures.__XlSiblingCount, measures.__XlChildCount } on columns,
    [Employee].[Location Code].&[01W]
    dimension properties MEMBER_TYPE
    on rows
    from [Metrics]
    cell properties value
    Also, I realise that I could change the collation on just the cube itself to case insenstive to get this to work, but I really don't want to do an impact analysis of running a mixed collation environment.
    So, my question is: Is there an excel fix that will allow me to run a case sensitve cube and allow me to click on filter and filter by "keep only selected items" or "Hide selected Items"? All other filtering works, it's only those two
    filtering options error for me.
    Here are the versions I'm working with:
    Excel 2013 (15.0.4535.1507) MSO(15.0.4551.1007) 32-bit Part of Microsoft Office Professional Plus 2013
    Microsoft Analysis Server Enterprise 2012 11.0.3000.0
    Any help would be appreciated. Thank you in advance!

    Hi, i assume this logic is for Dimension formula?
    If you have multiple hierarchy like ParentH1 and ParentH2 you should use FormulaH1 and FormulaH2 and not FORMULA column.
    in FORMULAH1
    [Account.H1].[Account_A] / [Account.H1].[Account_B]

  • How can I change all of (or more than one) speaker note to a voice at once?

    Hello... 
       I have a lot of speaker notes that I need to apply a specific voice to.  How do I apply the same voice to all of the speaker notes in the whole project at once?  Or at least more than one?  Any help would be appreciated.  Thank you!   I am working with Captivate 6.

    Hi Vikram,
      Thanks. That tip definitely helps!  You just have to be careful when you use the CNTRL button and not highlight the name of the slide as you try to highlight the voices.  If you do that, then the drop down box becomes “unclickable”.  Unfortunately, when using the control button, it is sometimes impossible not to highlight the name of the slide as well.
    Ryan
    Von: VikramGaur [email protected]
    Gesendet: Donnerstag, 20. September 2012 16:25
    An: Scharfer, Ryan
    Betreff: How can I change all of (or more than one) speaker note to a voice at once?
    Re: How can I change all of (or more than one) speaker note to a voice at once?
    created by VikramGaur<http://forums.adobe.com/people/VikramGaur> in Adobe Captivate - View the full discussion<http://forums.adobe.com/message/4713463#4713463

  • How can I enter my podcast in more than one category?  Mine covers arts, education and society and culture, but is listed as "Performing Arts".  Thank you for your time!

    How can I enter my podcast in more than one category, to reflect the fact that it covers arts, education and society and culture?  Thank you for your time!

    You can have more than one category - this page shows you how the tags are formed:
    http://www.apple.com/itunes/podcasts/specs.html#category
    The Store will list only the first category and its sub-category at the top of the page. Like the first category, the others will in theory make your podcast available for searching by category. However searching just on the category in the iTunes Store is most unlikely to throw up your podcast. There are thousands of podcasts out there, and it would be quite impossible to display on one page the entire list for any category. What you see are 'featured' podcasts, chosen by Apple as being special; please see this Tech Note:
    http://www.apple.com/itunes/podcasts/specs.html#getfeatured
    Note that there is no way you can influence the selection other than making your podcast really special.
    If you have further questions about making your podcast it's better to ask them in the Producing Podcasts forum.

  • How can a file be accessed by more than one app?

    Hi,
    I am new to iOS4 and the whole iPhone, iPod technology. I am really a windows user.
    How can a file be accessed by more than one app. In my case I want to transfer a midi file from my PC to my iPod Touch and be able to open it from a couple of Midi Players which I am evaluating - or does each Midi Player have to import the file seperately for its own use?
    Thanks,
    Sam

    It seems to me that what you want is exactly a session bean will do. The EJB container is responsible to maintain a certain number instances (configurable) of your session bean and serve multiple clients at the same time. Session beans are not necessarily destroyed after serving a client. If you configure your ejb server to have a pool size of 2 to 100, then you will always have at least 2 instances (no more than 100 even there are a lot of client access) of this ejb ready to serve. The only thing not clear to me is that do you want to use only ONE instance of this bean or you don't care as long as multiple clients can access this bean's service? Since you mentioned that there is not a real database access, you can certainly use a Singleton but a 'regular' session bean with static fields should do it also if these fields will not be modified by clients.
    PC

  • How to delete a page without deleting more than one

    how to delete a page without deleting more than one in pages

    Hi alldogsgotoheaven,
    Method 1.
    Menu > View > Show Thumbnails
    Click on a thumbnail.
    If it shows a yellow border around all the pages, they a part on a single section.
    Click in your document at the beginning of the page you want to delete, and Menu > Insert > Section Break.
    Insert another Section Break at the end of that page.
    The page is now isolated in its own section and you can delete its thumbnail.
    Regards,
    Ian.

  • How do I broadcast a wedding to more than one person?

    How can I broadcast a wedding to more than one person at a time?

    I missed your 2nd question.
    This article explains how to always show remote content and the risks of doing so. You can make that call. Adding your trusted senders to your address book will allow content from them and is the recommended action.
    http://kb.mozillazine.org/Privacy_basics_(Thunderbird)

Maybe you are looking for

  • FA Cost Detail Report Period wise

    Hi All Please help me in solving this .Youyr help is highly needed . We have scenrio where table has entry for PERIOD NAME ,ASSSET ID ,COST ADDITION ,COST DISPOSLE ,COST TRANSFER . We need to find the COST OPENING BALANCE and CLOSING BALANCE for each

  • Rebate Conditions issue (Pricing incorrect Order Viz Billing)

    Hi Forum, We have an issue with the rebate conditions. User has created a credit memo request (VA01) due to change in the Price. Due to this change rebate accruals have got reduced. The rebate accruals should not be reduced in this case, since there

  • How to save pdf in APEX 3.0

    is there a way to save the pdf output into APEX database in ver 3

  • Possible error when using ADFBC selectOneListbox in a master-detail page

    Hi Everyone, I'm trying to setup master - detail page with ADF BC, using Dept / Emp. I want to use a listbox for the master object, rather than the form + navigation commands as shown in the classic demos, so I've setup a listbox as following: <af:se

  • Db incarnation to older state

    working on oracle 10g v1 , xp run set until time "to_date('28-05-2009 09:15:00', 'dd-mm-yyyy hh24:mi:ss'); restore database ; recover database; error : media recovery failed alter database recover if needed start until time '28-05-2009 09:15:00' usin