String dilemma... how can I do this?

Sorry for the uninformative title.
Hello.
Lets say I have a string that looks like this..
String s = "1:0.375  2:0.33  5:0.244  88:433"What I need to do is, add 1 to every number preceeding the colon sign. In other words, the String should look like this:
String s = "2:0.375  3:0.33  6:0.244  89:433"Your help and feedback is much appreciated!

Sorry for the uninformative title.
Hello.
Lets say I have a string that looks like this..
String s = "1:0.375  2:0.33  5:0.244  88:433"What I need to do is, add 1 to every number
preceeding the colon sign. In other words, the String
should look like this:
String s = "2:0.375  3:0.33  6:0.244  89:433"Your help and feedback is much appreciated!See if it can help you...
import java.util.*;
public class Str
public static void main(String args[]) throws Exception
String s = "1:0.375  2:0.33  5:0.244  99:433";
StringTokenizer st = new StringTokenizer(s, " ");
StringBuffer sb = new StringBuffer();
while(st.hasMoreTokens())
      StringTokenizer st1 = new StringTokenizer(st.nextToken(), ":");
     while(st1.hasMoreTokens())
            int i = Integer.parseInt(st1.nextToken())+1;
             sb.append(String.valueOf(i)+":");
             sb.append(st1.nextToken()+" ");
System.out.println(sb);
}

Similar Messages

  • How can I write this string to a file as the ASCII representation in Hex format?

    I need to convert a number ( say 16000 ) to Hex string ( say 803E = 16,000) and send it using Visa Serial with the string control in Hex Mode. I have no problem with the conversion (see attached). My full command in the hex display must read AA00 2380 3E...
    I can easily get the string together when in Normal mode to read AA0023803E... but how can I get this to hex mode without converting? (i.e. 4141 3030 3233 3830 3345 3030 3030 3031 )
    Attachments:
    volt to HEX.vi ‏32 KB

    Sorry, The little endian option was probably introduced in 8.0 (?).
    In this special case it's simple, just reverse the string before concatenating with the rest.
    It should be in the string palette, probably under "additional string functions".
    (note that this only works in this special case flattening a single number as we do here. If the stat structure is more complex (array, cluster, etc.) you would need to do a bit more work.
    Actually, you might just use typecast as follows. Same difference.
    I only used the flatten operation because of the little endian option in my version.
    Message Edited by altenbach on 11-16-2007 11:53 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    littleendian71.png ‏4 KB
    littleEndiancast71.png ‏4 KB

  • When you create a link to a web page in numbers and we export the PDF file, the link is offset by 3 rows. Example: if I put a link on the text in cell A1, I found the link A4. In fact, this feature becomes unusable. How can we solve this problem? Thank yo

    When you create a link to a web page in numbers "Mavericks" and we export the PDF file, the link is offset by 3 rows. Example: if I put a link on the text (with Cmd-K) in cell A1, I found the link A4. In fact, this feature becomes unusable. How can we solve this problem?
    Thank you.

    Hi again Raja!
    I did as you recommended and installed HTTPWatch and below is the outcome of that program. It is the exact string with the only exception of obfuscated servernames and portnumbers. The last part that begins with "sap_ep_baseurl=" makes me suspicious, is that part really correct? It looks like it's lacking things.
    Best regards
    Benny
    http://<server:port>/sap/bc/bsp/sap/Z_PURCHASE_REQ/process.htm?
    sap-syscmd=nocookie&sap-client=200&sap-language=sv&style_sheet=
    http%3A%2F%2F<server>%3A<port>%2Firj%2Fportalapps%2F
    com.sap.portal.design.portaldesigndata%2Fthemes%2Fportal%2Fsap_tradeshow%2F
    controls%2Fcontrols_ie6.css%3F7.0.10.0.0&sap-cssversion=7.0.10.0.0&sap-tray-type
    =null&sap-tray-padding=null&sap-accessibility=&sap-ep-version=7.00.200611091758&
    sap_ep_version=7.00.200611091758&sap_ep_baseurl=http%3A%2F%2F
    <server>%3A<port>%2Firj%2Fportal&matnr=9780198603641

  • I am using Numbers on my iPhone5 and cannot get the app to do a simple (SUM) calculation.  It shows the formula correctly in the cell, but all I get for my long list of numbers to add is 0.  How can I get this to work?

    I am using Numbers on my iPhone5 and cannot get the app to do a simple (SUM) calculation.  It shows the formula correctly in the cell, but all I get for my long list of numbers to add is 0.  How can I get this to work?

    Oaky, at least we got that far.  Next step is to determine if all those "numbers" are really numbers.  Changing the format to "number" doesn't necessarily change the string to a number. The string has to be in the form of a number.  Some may appear to you and me as numbers but will not turn into "numbers" when you change the formatting from Text to Number. Unless you've manually formatted the cells to be right justified, one way to tell if it is text or a number is the justification. Text will be justified to the left, numbers will be justified to the right.
    Here are some that will remain as strings:
    +123
    123 with a space after it.
    .123

  • How can i use this sript and loade another movie?

    Hi there, i used the following script to load a movie from the server;
    var request:URLRequest = new URLRequest("url string");
    var loader:Loader = new Loader()
    loader.load(request);
    addChild(loader);
    How can i use this sript and loade another movie? Can someone help me please?
    [edited by moderator]

    Sir, I changed it from:
    var request:URLRequest = new URLRequest("http://agusandelsur.gov.ph/downloads/pdrrmo/agusan_del_sur/StaJosefa/Movies/Dir.swf");
    var loader:Loader = new Loader()
    loader.load(request);
    addChild(loader);
    to
    var request:URLRequest = new URLRequest("http://agusandelsur.gov.ph/downloads/pdrrmo/agusan_del_sur/StaJosefa/Movies/Warning.swf");
    var loader:Loader = new Loader()
    loader.load(request);
    addChild(loader);
    When i expord the movie i get the following error.....
    Scene 1, Layer 'Layer 3', Frame 1, Line 6    1151: A conflict exists with definition request in namespace internal.

  • Ps cs6 on mac. since installing yosemite, when working on an image if i want to change tool, via shortcut of wacom pen click, i now have to click on the image title bar, how can i fix this please?

    ps cs6 on mac. since installing yosemite, when working on an image if i want to change tool, via shortcut or wacom pen click, i now have to click on the image title bar, how can i fix this ?

    @Naiks, having suffered through unsuccessful synching attempts for Calendar and Contacts myself, l would suggest you try the following:
    UNINSTALL iCloud control panel from your PC. Seems silly, but do it.
    Go into Outlook, and look at the very top menu. Click FILE, then ACCOUNT SETTINGS, then click the popup box.
    You will see a list of all your email accounts. Make sure that ONE of them has a checkmark against it. If not, select the account your want as your default, and click "set as default.
    Exit out of Outlook and reboot your machine.
    Now reinstall iCloud, check CALENDAR and CONTACTS, and do as instructed when prompted.
    Reboot for good luck and now launch OUTLOOK. All that remains is to locate your iCloud Contacts and Calendar files, and make them your default.
    IMPORTANT: Don't panic if you can't find your contacts -- they're there. Click CONTACTS and you'll see you have several available contact files. Locate the one label "iCloud" in grey type. Right-click on it, select PROPERTIES, then click the Outlook Address Book tab. Check the box that says something like "Make this my default Outlook Address Book." Keep clicking "apply" and "okay" until you've exited out of the dialog box maze.
    You may have to do something similar with your Calendar files. I dd not, but if you need to, do it.
    Everything should now sync pretty seamlessly.
    I didn't have the exact same problem as you, but my dilemma was close enough. Good luck!
    Arthur P. Johnson

  • How can I move columns in Numbers without distorting the formula in other cells?  In Excel I can cut and paste entire columns and the formula in other cells adjusts accordingly.  When I do it in Numbers, the formula messes up.  How can I do this?

    How can I move columns in Numbers without distorting the formula in other cells?  In Excel I can cut and paste entire columns and the formula in other cells adjusts accordingly.  When I do it in Numbers, the formula messes up.  How can I do this?
    For example: I have formulas in columns D and F that relate to columns C to CU
    If I want to move one column from one position to another (say S to T), the formula loses the colums that was moved, i.e. it doesn't recognize it has moved, rather sees it as deleted...  How can I do this without distorting the formula?

    Thanks for the feedback.
    If I often urge askers to look at the available resources, it's because  a large range of questions asked in the forums are already answered in these documents.
    As they are PDFs, they are easy to search in.
    CAUTION
    Download them while they are available.
    Given what is delivered with iBooks Author, I'm afraid that we will not get such easy to use documents.
    Searching infos in the  iBooks Author documentation available on line is awfully cumbersome and a lot of embedded links are wrongly flagged this way. In the Help files they aren't links but underlined strings.
    It seems that the tool used to generate the web pages was wrongly configured.
    Yvan KOENIG (VALLAURIS, France) dimanche 22 janvier 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My Box account  is : http://www.box.com/s/00qnssoyeq2xvc22ra4k
    My iDisk is : http://public.me.com/koenigyvan

  • ITunes not displaying Talking Walking podcasts – how can I resolve this?

    iTunes not displaying Talking Walking podcasts – how can I resolve this?
    http://www.talkingwalking.net
    Created on iWeb version 3.0.4
    Mac OS X 10.6.8 (10K549)
    Upgraded to Snow Leopard in August 2010 from Tiger.
    Originally published 26 podcast episodes using IWeb to MobileMe and successfully had them in the iTunes store.  Then upgraded to Snow Leopard and had consistent problems publishing through iWeb, with messages appearing saying that the site hadn’t published on MobileMe or that the upload had timed out. 
    This meant that I had to upload the whole site whenever I made a slight change or published a new episode. Some of the pages failed to completely load on the website, and none of the new episodes appeared in the iTunes store.  However, it was still possible to subscribe to the new episodes through the website Subscribe button.
    Earlier this year, the original 26 episodes vanished from the ITunes store. 
    At the end of June, I moved my server from MobileMe to Rage and subsequently the website publishes without any time out messages or pages not fully functioning.  This means that when I come to make updates or add a new episode, I can speedily upload changes. 
    I have tried to resubmit the feed for the website to the iTunes store but Talking Walking still does not appear in the store (nor do any of the links to the individual podcasts from the website work), however, you can still subscribe to podcasts, but now only those uploaded since August 2010.
    I have sent an e mail to iTunes explaining my dilemma but have had no reply.
    Would welcome any suggestions as to how I can rectify this issue.  Next year is the fifth anniversary of Talking Walking podcasts and it would be nice to see them available again through the iTunes store.
    With thanks, Andrew
    [email protected]

    Your feed is at http://www.talkingwalking.net/public/Talking_Walking/rss.xml . It contains episodes running from 23 February 2008 to 20 September 2012 and when you subscribe to this feed in the iTunes application all the episodes appear. The link on your web page is to this feed, so subscribing from the page works OK,
    Searching for 'Talking Walking' in the iTunes Store produces a lot of result, none of them relevant or yours. This rather suggests that your podcast has been removed from the Store - if the feed wasn't functioning for an appreciable time this would be a normal reason for removal.
    if your feed was originally on MobileMe and you have moved it to another server you have to tell the iTunes Store about this by adding a special tag to the feed - details here:
    http://www.wilmut.webspace.virginmedia.com/notes/podcast.html#move
    If you did not do this - and it's now too late - the Store will have been stuck looking for the non-existent old feed, which will very likely get your podcast removed.
    You mention seeing the web page for the Store page - it's not possible to check this unless you post the URL.
    If the podcast has been removed from the Store you will have to re-submit it as a new one. Unfortunately there is a bug in the automated part of the submissions process which will tell you the feed has already been submitted, even when it's been removed. In order to get round this you will have to change the title of the feed slghtly. You can always change it back later provided that doing so does not change the feed URL - I think this may well happen if you are using iWeb, so be cautious about this.

  • How can i  apply this  java program for  a jsp page?

    import java.io.*;
    import java.util.*;
    public class FileProcessing
      //create a vector container  for the input variables
         Vector variables = new Vector();
      //create a vector container for the constants
         Vector constants = new Vector();
      /*create a string expression container for the equation
         as read from the file */
         String expression = " ";
      //create double result container for the final result
         double result = 0;
         public boolean processFile(String filename,String delim)
          //index for values vector
              int num_values = 0;
          //index for constants vector
              int num_constants = 0;
          //current line being read from the external file.
              String curline = " ";
          //start reading from the external file
              try
                   FileReader fr = new FileReader(filename);
                   BufferedReader br = new BufferedReader(fr);
                   while(true)
                        curline = br.readLine();
                        if(curline == null)
                             break;
                    //determine the type of current interaction
                        boolean variable = curline.startsWith("input");
                        boolean constant = curline.startsWith("constant");
                        boolean equation = curline.startsWith("equation");
                        boolean output = curline.startsWith("result");
                   //on input variables
                        if(variable)
                          StringTokenizer st = new StringTokenizer(curline,delim);
                          int num = st.countTokens();
                          int count=0;
                          while(st.hasMoreTokens())
                               String temp = st.nextToken();
                               if(count==1)
                                    byte b[]= new byte[100];
                                    System.out.println(temp);
                                    System.in.read(b);
                                    String inputval = (new String(b)).trim();
                                    variables.add(num_values,inputval);
                                    num_values++;
                               count++;
                        // on constant values
                        if(constant)
                             StringTokenizer st = new StringTokenizer(curline,delim);
                             int num = st.countTokens();
                             int count = 0;
                             while(st.hasMoreTokens())
                                  String temp = st.nextToken();
                                  if(count==1)
                                       byte b[]= new byte[100];
                                       System.out.println(temp);
                                       System.in.read(b);
                                       String cons = (new String(b)).trim();
                                       constants.add(num_constants,cons);
                                       num_constants++;
                                  count++;
                        // on equation
                        if(equation)
                             StringTokenizer st = new StringTokenizer(curline,delim);
                             int num = st.countTokens();
                             int count = 0;
                             while(st.hasMoreTokens())
                                  String temp = st.nextToken();
                                  if(count==2)
                                       this.expression = temp;
                                  count++;
              // now we are ready to evaluate the expression
                       if(output)
                          org.nfunk.jep.JEP  myparser= new org.nfunk.jep.JEP();
                          myparser.setAllowAssignment(true);
                          for(int i=1;i<variables.size()+1;i++)
                             String name = "arg"+Integer.toString(i);
                             myparser.addVariable(name,new Double(variables.get(i-1)
                                                .toString()).doubleValue());
                          for(int i=1;i<constants.size()+1;i++)
                               String name = "arg" +Integer.
                                         toString(i+variables.size());
                               myparser.addConstant(name,new Double(constants.get(i-1).toString()));
                   //output is obtained as follows
                          myparser.parseExpression(expression);
                          result = myparser.getValue();
                          System.out.println("Assay value: "+result);
              catch(Exception e)
                   System.out.println(e.toString());
              return true;
         public static void main(String[] args)
              FileProcessing fp = new FileProcessing();
              fp.processFile("input.eqn",":");
    }//my text file name is: "input.eqn" (given below)
    input:Enter Value1:arg1
    input:Enter Value2:arg2
    input:Enter Value3:arg3
    constant:arg4
    constant:arg5
    Equation:arg1+arg2+arg3
    result:

    how can i apply this java program for a jsp pagewhy do you want to do this ?
    Your program reads from a file on the disk and formats based on a patterm.
    Jsp is not intended for such stuff.
    ram.

  • I'm trying to create a program that will allow me to collect data from a Luxtron thermometr​y system. How can I do this?

    I'm a little confused as to how to write to the machine and how to retrieve data from the machine. I'm unsure of requested byte size and string to write specifically. This machine also has 4 probes, so it can record 4 temperatures simultaneously. How can I reflect this in the waveform chart?

    There are example VI's in LV on Instrument Connectivity. If you go to the Help menu >> Examples.. >> I/O, you will see a couple; and Examples.. >> Fundamentals for File and String manipulation. I would suggest tweaking them to suit your application. Also the specific command that your instrument responds to can be found from it's manual.
    You could find a driver for this instrument at http://www.ni.com/devzone/idnet/default.htm . If it's not listed there, it leaves you with one of a couple options. First, I would like you to submit a request for this driver at: http://zone.ni.com/idnet97.nsf/instrumentdriverreq​uest/
    We develop drivers based on demand and popularity so the more requests we have for it, the greater the possibility that we will develop one.
    If y
    ou would like to try developing your own instrument driver (or modify the existing one), we have documentation, model instrument drivers, and driver templates to help at :
    http://www.ni.com/devzone/idnet/development.htm
    We also have a syndicate of third party vendors that specialize in National Instruments' products and services. Some of the vendors specialize in driver development. I would suggest contacting one of the Alliance members at:
    http://www.ni.com/alliance
    Some useful resources for your application are
    ni.com > NI Developer Zone > Development Library > Instrument Connectivity
    http://search.ni.com/?col=alldocs&layout=TechResou​rces&ql=a , to search examples and knowledge bases
    Hope this helps.

  • How can i convert this data(00000000) into date format(yyyy-MM-dd)

    Hi,
    i am using this method to convert date format from string.
    public static string FormatDate(string inputDate, string inputFormat)
                System.DateTime date = DateTime.ParseExact(inputDate, inputFormat, null);
                string datepresent = DateTime.Now.Date.ToString("yyyy-MM-dd");
                return datepresent;
    its working properly,
    but when input data is like 00000000 i am getting error this is not valid.
    how can i convert this into date format any help..!

    Have you tried the above code:
    I can see it is working with both Date and DateTime destination nodes.
    Map:
    Functoid Parameters:
    Functoid Script:
    public static string FormatDate(string inputDate, string inputFormat)
    string datepresent;
    if (inputDate == "00000000")
    datepresent = "0000-00-00";
    else
    System.DateTime date = DateTime.ParseExact(inputDate, inputFormat, null);
    datepresent = date.ToString("yyyy-MM-dd");
    return datepresent;
    Input:
    <ns0:InputDateString xmlns:ns0="http://DateFormat.SourceSchema">
    <DateString>00000000</DateString>
    </ns0:InputDateString>
    Output:
    <ns0:OutputDate xmlns:ns0="http://DateFormat.DestinationSchema">
    <Date>0000-00-00</Date>
    </ns0:OutputDate>
    If this answers your question please mark as answer. If this post is helpful, please vote as helpful.

  • I would like to run the vi first and then press the safe button to write it to disk.i am sending you the vi. please can you tell me how can i correct this vi?

    i am running some vis in frames of sequence frome frame number 1 to frame 10.after this i would like to create one other vi with some strings and i want to save it to disk with a save button. i am opening,writing and closing the data.what i want is that a save button to write the file .moreover i would like to run the application first and then press the safe button to write it to disk.i am sending you the vi. please can you tell me how can i correct this vi?
    Attachments:
    savestrings.vi ‏80 KB

    Here's a picture of a while loop around part of your code. All it's doing is waiting to write until the user presses the save button. If you need it to do more, explain in more detail.
    Attachments:
    While_Loop.jpg ‏17 KB

  • How can i read this response?

    i hav a encrypted string subsinfo, & i forward it to dec.jsp to be decrypted & it result :
    HTTP_RESPONSE
    msisdn|firstname|lastname
    how can i read this response so i can have the parameter string newsubsinfo = msisdn|firstname|lastname ?

    Hi ,
    You can read request parameters and store in a Container or Global container object and use them in response mapping as per requirement .
    Use Container / Global container - you can save your parameters as key value pair and retrive it using the key and attach these parameters to response structure and access them .
    Nanda

  • I have firefox 4.0 beta 11. i want to install latest version of firefox 4.0. but when i install 4.0 nothing changes.how can i solve this problem?

    I have firefox 4.0 beta 11. I want to install latest version of firefox 4.0. But when i install 4.0 nothing changes. How can i solve this problem? I tried to install 3.6 then install 4.0, but the same thing happened again.

    According to your user agent string you are using Firefox 4 and not beta 11

  • ITunes disables my CD drives when I installed. How can I correct this problem.

    ITunes disables my CD drives when I installed. How can I correct this problem?

    1.Open about:config in Firefox (simply type about:config into the address bar and hit enter, if you doing it for the first time, you may have to promise you are going to be careful)
    2. Search for keyword.url from the filter box at the top.
    3.Double click on this entry. It will open a dialog where you can edit the ‘keyword.url’ string
    4. delete anything in there (if there is anything) and copy in the following:
    http://www.google.com/search?ie=UTF-8&sourceid=navclient&gfns=1&q=

  • When i double click itunes it doesn't open it just comes up with an error saying " The itunes library.itl file cannot be found or created. The default location for this file is in the 'itunes' folder in the 'music' folder". How can i fix this?

    When i double click itunes it doesn't open it just comes up with an error saying " The itunes library.itl file cannot be found or created. The default location for this file is in the 'itunes' folder in the 'music' folder. How can i fix this problem?

    Anyone can help to advice how to solve this issue ?

Maybe you are looking for

  • OEM grid 10g installation steps on RHEL 5.4

    Please provide the steps and note ids for OEM grid 10g/11g installation on linux 5 we are on 2 node RAC running on Red Hat Enterprise Linux Server release 5.4 (Tikanga) uname -a Linux clelx062ptlge.penske.com 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48

  • How do you advance one line at a time (text) within each slide?

    In PowerPoint you can either present an entire slide at one time or make each bulleted line in the slide appear line by line as you click the mouse button. I cannot figure out how to do this in Captivate. I am only able to advance an entire slide at

  • Labview executable does not open excel...

    i just compiled labview code into an executable and when i run the executable, it does not open an excel document like it is supposed to.  it opens the excel program, but not the specific file stipulated in the code. the problem only exists on one of

  • Change the image resolution through iPhoto

    Does anyone know how to change the image resolution through iPhoto? I know it can be done in other image editing software, but I have yet to find it as an option in iPhoto.

  • Custom size photos with iPhoto 6?

    Hi, I'm trying to print a photo in passport size (which is 2x2, I believe). I found directions for doing this with iPhoto 08, but not iPhoto 6 (which is what I have). Can this be done with the older version of iPhoto? Thanks, Hania