How can I convert a string to a seperated characters?

How can I convert a string to a separated characters without using array?
such as: input = String "word"
output =
w
o
r
d
Thanks

A string is stored internally in individual characters.
The String class has a method 'charAt(int index)' which returns the character at that index so using a for loop..
String s = "word";
for(int counter=0; counter < s.length(); counter++)
System.out.println(s.charAt(counter));
HTH

Similar Messages

  • How can I convert a String into an int?

    I need to use command-line args. So I enter "java Main 123" and I want to use 123 not as a String but as an int.
    How can I convert it into an int?
    Thank You!!
    Sprocket

    Example method (you don't need to use a method unless you do this a lot)
    private int stringTOInt (String aString)
    int result = 0;
    try
    result = Integer.parseString(aString);
    catch (Exception ex)
    System.out.println ("Failed to convert string " + aString + " to int.");
    return result;
    }

  • How can I convert a string of hex values to a hex format string programatically?

    Is there a way to convert a string of the following format:
    1400010107070D0305006A01 ........           ("Normal display" string)
    programatically to:
    1400 0101 0707 0D03 05006A01 ..........      ("Hex display" striing)
    I need to do this in order to calculate a CRC16 value.
    See attached VIs
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    CMM_SN_MULTI.vi ‏50 KB
    CMM_CRC16_Calculator.vi ‏23 KB

    You can iterate over the string and use the String to Hex VI. If you work with two bytes of the string at a time you can get a U8 array of the desired binary values. Then when you are complete you can either work with the byte array of convert it back to a string using Byte Array to String.
    EDIT: GerdW typed faster than I did.
    Message Edited by Mark Yedinak on 03-18-2010 02:55 PM
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • How can I convert a String to a DOM document?

    I want to convert the text of a TextArea to a DOM Document - how can I do this?
    Thanks a million,
    Daniel.

    something.parse(new StringReader(theTextArea.getText()));

  • How can I convert a string into an image

    I want to convert a string into an image.
    I want to know required steps for that.

    look at http://forum.java.sun.com/thread.jsp?forum=31&thread=194763
    drawString looks as something you might need

  • How can I convert a string to an object or class

    I would like to read a file representing a class, and convert it to an object or a class (object preferred). Other postings suggest using javax.tools.JavaCompiler to convert from a string but then say that this is not always available (posting on 1 Jan 09). If this is still not universally available is there another way to do this? If this is not available, are there any examples of how it should be done?
    My understanding from what I've read is to read the file into a String then compile the String using javax.tools.JavaCompiler, which is an Interface.
    thanks

    skidmarks wrote:
    What i would like to do is to take a Java file representing a class and compile it at runtime. However, the comment about a JDK being available at runtime makes this unattractive.So, you want to compile .java files, but you don't want to have to use a compiler?
    The next guess would to be to create a .jar file and reference it at runtime. Here's the scenario:Eh? How is that even remotely equivalent?
    1. People using the 'system' will have a varied knowledge of Java.
    2. My hope was to require that anyone using the program would only need to create a Java Class file,You mean a Java source file. You have said that YOU want to create the .class file. If they are creating the .class file, then all you need to do is load it with a ClassLoader and start using it.
    You might try clarifying your requirements a bit.
    In either case, the Class Files would look like:
    public class Name {
    int field1;
    float field2;
    } With all the field types being simple Java Primitives.What is the point of this? What are you ultimately trying to accomplish, that can be served by user-defined groups of primitives, with no complex object graphs and no user-defined methods?
    Depending on what you're really getting at, using scripting features via beanshell, groovy, or javascript might be an approach to consider, or using Scala to produce a domain-specific language (although I suspect that last may be overkill, and beyond your current skill level).
    If this is so, is there any way to create a .jar file at runtime? Do I have to exec("jar") or is there another way.A .jar file is just a .zip file with a manifest. Look at the java.util.jar package. But note that creating a .jar file has nothing to do with the rest of what you're asking about.

  • How can I convert a String into boolean?

    I am facing difficulty in converting String into boolean.
    For example, I have a few variable which i need user to input yes or no as the answer. But I uses string instead. Is there a way which i can ask them to input boolean directly?
    Please advise...
    credit = JOptionPane.showInputDialog("Enter Yes or No for Credit Satisfactory : ");
    System.out.println("The answer for Credit Satisfactory : "+credit);
    e_invtry=JOptionPane.showInputDialog("Enter Yes or No for inventry level");
    System.out.println("The answer for Quantity Order : "+e_invtry);
    Message was edited by:
    SummerCool

    Thanks...but I don't get it....I tried to use your
    suggestion but i got the message that " cannot find
    symbol method
    showConfirmDialog(java.lang.String,int)" ???
    Please advise.
    The code I use was :
    int credit = JOptionPane.showConfirmDialog("Enter Yes
    or No for credit satisfactory",
    JOptionPane.YES_NO_OPTION);Well that was not the example I gave you.
    JOptionPane has no method showConfirmDialog that receives a String and an int (exactly what the error message is telling you).
    What was wrong with the version I showed you?

  • How can i convert a string to use on a image property?

    public function excluir(nome:Image):void
                                            nome.enabled = false;
    it's simple...
    I'm trying to use a string who comes from the db to set on image property.
    it's like -> id.enabled = false

    Hi,
    What are you trying to do?
    s:Image is a component in flex, with source property you set the path and name of the image for the s:Image component.
    http://help.adobe.com/en_US/Flex/4.0/UsingSDK/WS2db454920e96a9e51e63e3d11c0bf69084-7f9d.ht ml
    If you have a list of images path in the database you can probably read all in arrayCollection and add those images in a list like:
    http://livedocs.adobe.com/flex/3/html/help.html?content=dpcontrols_2.html
    I hope this help

  • How can I convert string to the record store with multiple records in it?

    Hi Everyone,
    How can I convert the string to the record store, with multiple records? I mean I have a string like as below:
    "SecA: [Y,Y,Y,N][good,good,bad,bad] SecB: [Y,Y,N][good,good,cant say] SecC: [Y,N][true,false]"
    now I want to create a record store with three records in it for each i.e. SecA, SecB, SecC. So that I can retrieve them easily using enumerateRecord.
    Please guide me and give me some links or suggestions to achieve the above thing.
    Best Regards

    Hi,
    I'd not use multiple records for this case. Managing more records needs more and redundant effort.
    Just use single record. Create ByteArrayOutputStream->DataOutputStream and put multiple strings via writeUTF() (plus any other data like number of records at the beginning...), then save the byte array to the record...
    It's easier, it's faster (runtime), it's better manageable...
    Rada

  • How can I convert a space from ABAP to CSV data?

    Hello guys,
    how can I convert a string like
    "This is a%test%"
    to
    "This is  a test "
    into CSV data?
    I try to with   REPLACE ALL OCCURRENCES OF '%' IN string_above WITH space,
    but I got the string without space, like
    "This is  atest"
    I read some posts that CSV will ignore space.
    But which kind of symbol in CSV represents space?
    Thanks for any suggestion!
    Regards,
    Liying

    USE THE CODE AS SHOWN BELOW...
    TYPES : BEGIN OF tp_data,
              line(4096),
            END   OF tp_data.
    *&      Form  gui_upload
          Upload the data from the input file to the internal table
    FORM gui_upload.
    *--Local data declaration
      DATA: l_filename_ip TYPE string,
            tl_data       TYPE STANDARD TABLE OF tp_data WITH HEADER LINE.
      l_filename_ip = p_input.
    *--Upload Data
      CALL FUNCTION 'GUI_UPLOAD'
           EXPORTING
                filename                = l_filename_ip
                filetype                = 'ASC'
                has_field_separator     = ''
           TABLES
                data_tab                = tl_data
           EXCEPTIONS
                file_open_error         = 1
                file_read_error         = 2
                no_batch                = 3
                gui_refuse_filetransfer = 4
                invalid_type            = 5
                no_authority            = 6
                unknown_error           = 7
                bad_data_format         = 8
                header_not_allowed      = 9
                separator_not_allowed   = 10
                header_too_long         = 11
                unknown_dp_error        = 12
                access_denied           = 13
                dp_out_of_memory        = 14
                disk_full               = 15
                dp_timeout              = 16
                OTHERS                  = 17.
      IF sy-subrc <> 0.
        MESSAGE ID   sy-msgid TYPE 'S' NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        IF sy-subrc = 1.
          MESSAGE e000 WITH text-e04.
        ENDIF.
      ELSE.
        LOOP AT tl_data FROM 2.
    *--Taking the contents of the input file leaving the header part
          PERFORM split_and_save USING tl_data-line.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " gui_upload
    *&      Form  split_and_save
          Splitting the contents from the input file and saving them into
          an internal table
         -->P_TL_DATA_LINE  text
    FORM split_and_save USING fp_data.
    *--Local data declaration
      DATA : tl_data TYPE STANDARD TABLE OF tp_data WITH HEADER LINE,
             l_type  TYPE c,
             c_space(1) TYPE c VALUE ' '.
    *--Split at the Comma
      SPLIT fp_data AT c_space INTO TABLE tl_data.
      CLEAR inputtab.
    *--Move it to the target fields
      DO.
        ASSIGN COMPONENT sy-index OF STRUCTURE inputtab TO <fs_field>.
        IF NOT sy-subrc IS INITIAL.
          EXIT.
        ENDIF.
    *--Extract source data
        CLEAR tl_data.
        READ TABLE tl_data INDEX sy-index.
    *--Populate the target
        <fs_field> = tl_data-line.
      ENDDO.
    *--Append this record
      APPEND inputtab.
    ENDFORM.                    " split_and_save
    In the above code u can use make inputtab like tp_data and get the result as requires in an internal table as space seperated fields.
    In place of space u can also use any other symbol.
    And after that u can replace all occurences of space with the comma by using the statement that u have written below.

  • How can I convert an int to a string?

    Hi
    How can I convert an int to a string?
    /ad87geao

    Here is some the code:
    public class GUI
        extends Applet {
      public GUI() { 
        lastValue = 5;
        String temp = Integer.toString(lastValue);
        System.out.println(temp);
        showText(temp);
      private void showText(final String text) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            tArea2.setText(text + "\n");
    }

  • How can I convert  an ArrayList to a String[]

    Hi,
    How can I convert an ArrayList (only with strings) to a String[] ?
    I've tried this :
         public static String listToString(List l) {
              StringBuffer sb = new StringBuffer();
              Iterator iter = l.iterator();
              while (iter.hasNext()) {
                   sb.append(iter.next().toString());
                   if (iter.hasNext()) {
                        sb.append(',');
              return sb.toString();
    But what I get is an array of xxxxx@435634 (for example).
    Thanks a lot !

    Strings are Objects but not all Objects are Strings and at least one of the elements in your List is not a String.

  • How can I convert output data (string?) from GPIB-read to an 1D array?

    Hello all,
    I am reading a displayed waveform from my Tektronix Oscilloscope (TDS3032) via the GPIB Read VI. The format of the waveform data is: positive integer data-point representation with the most significant byte transferred first (2 bytes per data point).
    The output data of GPIB-Read looks like a string(?) where the integer numbers and a sign like the euro-currency sign are seperated by spaces e.g. #5200004C3 4 4 4 4 3C3C3........ (C represents the euro-currency sign).
    How can I convert this waveform data into a 1D/2D array of real double floatingpoint numbers (DBL) so I can handle the waveform data for data-analysis?
    It would be very nice if someone know the solution for this.
    t
    hanks

    Hi,
    First of all, I'm assuming you are using LabVIEW.
    The first you need to do is parse the string returned by the instrument. In this case you need to search for the known symbols in the string (like the euro sign) and chop the string to get the numeric strings. Here are some examples on parsing from www.ni.com:
    Keyword Search: parsing
    Once you parse the numeric strings you can use the "String/number conversion VIs" in the String pallette.
    Hope this helps.
    DiegoF.Message Edited by Molly K on 02-18-2005 11:01 PM

  • How can I convert the variable expression stored as string back to variable expression

    How can I convert the variable expression stored as string back to variable expression?
    I am storing the expression enterd in the TSExpresssionEditControl as simple string and want to convert back to expression since I want to get the data type of that expression.

    pritam,
    I'm not sure what you're trying to do exactly. If you are trying to get the value of a variable and you only have the name of value in a string, then you can use Evaluate() to get its value. If you want the data type, my advise is to use the GetPropertyObject() API method and just pass in the loop up string. Then you'll have a handle to the data object and then proceed from there.
    Regards,
    Song D
    Application Engineer
    National Instrument
    Regards,
    Song Du
    Systems Software
    National Instruments R&D

  • CS3/CS4/CS5 Win/Mac: How can I convert a Windows string to mac?

    Hi
    I have a Windows coded string. I like to convert this string into a Macintosh string. This means several characters are changed, e.g. ä, ö or ü.
    Is there a method in the Indesign SDK?
    How can I convert a windows string into a macintosh string and back?
    Thanks
    Hans

    I don't think this should work that way. If this string is in resource file, use UTF-8 encoding and make PMString do its job. use kResourceUTF8Encoded in StringTable:
    resource StringTable (kSDKDefStringsResourceID + index_enUS)
            k_enUS,                                             // Locale Id
            kResourceUTF8Encoded,                         // Character encoding converter (irp) I made this WinToMac as we have a bias to generate on Win...
                  // ----- Menu strings
                    kWFPCompanyKey,                         kWFPCompanyValue,
                    kWFPAboutMenuKey,                         kWFPPluginName "[US]...",
                    kWFPPluginsMenuKey,                    kWFPPluginName "[US]",
                        kWFPDialogMenuItemKey,               "Show dialog[US]",
                    kSDKDefAboutThisPlugInMenuKey,               kSDKDefAboutThisPlugInMenuValue_enUS,
                    // ----- Command strings
                    // ----- Window strings
                    // ----- Panel/dialog strings
                        kWFPDialogTitleKey,     kWFPPluginName "[US]",
                        kWFP_Tuna_Key,     "Tuna",
                        kWFP_Salmon_Key,     "Salmon",
                        kWFP_Bonito_Key,     "Bonito",
                        kWFP_Yellowtail_Key, "Yellowtail",
                        kWFP_Currency_Key, "$",
              // ----- Misc strings
                    kWFPAboutBoxStringKey,               kWFPPluginName " [US], version " kWFPVersion " by " kWFPAuthor "\n\n" kSDKDefCopyrightStandardValue "\n\n" kSDKDefPartnersStandardValue_enUS,
    Message was edited by: Maciej Przepióra

Maybe you are looking for

  • Erro de Validação SCS = 9

    Bom dia pessoal, tudo bem? Estamos atualizando a NFE 2.0 no ambiente QAS. Após a geração da NFE, retornou o status para J1BNFE da seguinte forma: - status ação: em comunicação (rodinha) - log NFE: verdinho - status do documento: branco - status de co

  • Problems with Time machine caused by removing PKCS11.log?

    I haven't yet found a solution to my Time Machine no longer backing up: "while an error occurred while copying files to the backup disk" I requested help before, but so far nobody could help me solve this problem! I noticed that I removed, in a file

  • SRM PO form.

    HI friends, I'm quite new to SRM. I've to make some changes to std. PO form in SRM.like logo. Can you tell me Step by step what are the basic config required.? Also can anyone please forward me a sample techinical spec on SRM PO Smartforms, which I c

  • I Can't open My Products to update my charge card.

    I have 11 days to get into My Products page to update the new expiration date on my charge card so that I can have my The Cloud monthly charge processed.  When I sign in and to to My Product page, after 15 minutes or more, it will not open.

  • My husband used Bootcamp to give his entire hard drive to Windows, but would now like Mac OS back.

    So, I figured I would be able to handle it by restoring his Macbook to factory defaults like I had done with mine in the past. Wrong. There were two options, as far as a location to install. Something or other "reserved" and where Windows was install