How to convert a String to an array

Can somebody tell me how to convert a String to an array

ronisto wrote:
Can somebody tell me how to convert a String to an arrayI assume you mean to convert it into an array of the individual characters that comprise the String.
Can you not simply look at the API documentation? Nothing in the String API jumps out at you?
http://java.sun.com/javase/6/docs/api/index.html

Similar Messages

  • How to convert a string value to date

    Dear All,
    I am new to powershell script, i was trying to store a Ad user password set date to a variable add, add a number of days to get the expire date.
    but when i try to convert the variable to date value, I am getting the error as below.
    Please help me......
    PS C:\script> $passwordSetDate = (get-aduser user1 -properties * | select PasswordLastSet)
    PS C:\script> $passwordSetDate
    PasswordLastSet
    7/15/2014 8:17:24 PM
    PS C:\script> $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
    Cannot find an overload for "ParseExact" and the argument count: "3".
    At line:1 char:1
    + $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodException
        + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    PS C:\script> $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)

    Dear All,
    I am new to powershell script, i was trying to store a Ad user password set date to a variable add, add a number of days to get the expire date.
    but when i try to convert the variable to date value, I am getting the error as below.
    Please help me......
    PS C:\script> $passwordSetDate = (get-aduser user1 -properties * | select PasswordLastSet)
    PS C:\script> $passwordSetDate
    PasswordLastSet
    7/15/2014 8:17:24 PM
    PS C:\script> $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
    Cannot find an overload for "ParseExact" and the argument count: "3".
    At line:1 char:1
    + $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodException
        + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    PS C:\script> $a = [datetime]::ParseExact($passwordSetDate,"MM/dd/yyyy HH:MM:SS", $null)
    In your post you ask how to convert a string value to a date.  The value returned from the Get-AdUser is already a date.  It does not need to be converted.
    Bill has sshown one way to convert a date to a string and there are other methods.  You need to clarify your question.
    If you are really trying ot convert strings to dates then you can start with this:
    [datetime]'01/21/1965 13:33:23'
    Most date strings aer autodetected by the class.
    ¯\_(ツ)_/¯

  • How to convert a String("yyyy-mm-dd") to the same but in Date format ?

    Hi,
    can anyone plz tell me how to convert a String to a date format.I'm using MSACCESS database.I want to store this string in the database.So i need to convert it to a date format since the table is designed such a way with date/time type for date field.I used SimpleDateFormat ,but i can't able to convert.The code is given below:
    coding:
    public String dateconvertion(String strDate)
    try
    SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd");
    Date date = sdfSource.parse(strDate);
    SimpleDateFormat sdfDestination = new SimpleDateFormat("yyyy-MM-dd ");
    strDate = sdfDestination.format(date);
    catch(ParseException pe)
    System.out.println("Parse Exception : " + pe);
    return(strDate);
    }

    i used prepared statement even now i am getting error like this.....
    i have included the prepared statement package also...
    my coding:
    ResultSet rsdatetemp = null;
    PreparedStatement ps = null;
    String query ="select distinct itemcode from sales where bill date between ? and ?";
    ps = precon.prepareStatement(query);
    ps.setDate(1,d1);//d1 and d2 are in date format
    ps.setDate(2,d2);
    rsdatetemp = ps.executeQuery();
    error :
    symbol : method setDate(int,java.util.Date)
    location: interface java.sql.PreparedStatement
    ps.setDate(1,d1);
    symbol : method setDate(int,java.util.Date)
    location: interface java.sql.PreparedStatement
    ps.setDate(2,d2);

  • Converting XML String to MessageElement array

    Hi,
    I am trying to call a .NET web service from my Java client. I used WSDL2Java to generate the java classes for calling the .NET web service. The generated classes to call the service expects an array of org.apache.axis.message.MessageElement objects. I have a string representing an XML document which looks like this:
    String xmlString = "<Results><Adjustments><Adjustment><RebuildAdjustmentID>16</RebuildAdjustmentID><IsBasicAdjustment>true</IsBasicAdjustment><AdjustmentType>stone/AdjustmentType><Title>External walls</Title></Adjustment></Adjustments></Results>"
    I have tried converting the string into an array of MessageElement objects by the following way:
    MessageElement[] m = new MessageElement[1];
    Document XMLDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(result2.toString())));
    m[0] = XMLDoc.getDocumentElement();
    However I keep getting the following message returned from the service:
    "Object reference not set to an instance of an object"
    I have tried a handful of ways but keep getting this same error. I have searched the web for hours looking for a solution to this problem without success so any help/ideas much appreciated,
    Thanks.
    Paul

    Any updates on this?
    I am facing a similar problem.

  • How to convert a String to an Icon

    Hello,
    I'm trying to figure out how to convert a String (specifically one letter) to an Icon for a JTree. The program I am working on uses .png files for the icons at the moment, with each .png being a single uppercase letter. However, recent discussion has us wanting to change to something more dynamic, since we anticipate needing new letters in the near future.
    My task is to modify the current codebase so that the Icons used to identify nodes in the tree are created from a Font within code, rather than reading in .png files. I have done some experimenting with creating a Label with just that String, setting the font and trying to extract the image using calls like createImage(int width, int height) and so on, but so far to no avail.
    If I could figure out how to at least convert the String to an image, I could probably make it work (since I can play around with creating an ImageIcon with that image). Thanks in advance for any help.
    Allan

    Here is some quick and dirty code:
    import java.awt.*;
    import javax.swing.*;
    public class BasicIcon implements Icon {
        private String text;
        public BasicIcon(String text) {
            this.text = text;
        public int getIconWidth() {
            return 16;
        public int getIconHeight() {
            return 16;
        public void paintIcon(Component c, Graphics g,  int x, int y) {
            Color old = g.getColor();
            g.setColor(c.getForeground());
            g.drawString(text, x, y+13);
            g.setColor(old);
        public static void main(String[] args) {
            JPanel cp = new JPanel();
            for (char ch = 'A'; ch < 'F'; ++ch) {
                cp.add(new JButton("letter " + ch, new BasicIcon(String.valueOf(ch))));
            JFrame f = new JFrame("BasicIcon");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(cp);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }One thing that could be improved is the vertical positioning of the letter in the Icon.
    The x,y values passed into paintIcon are the upper-left hand corner of the icon,
    but the y value needed by drawString is the position of the String's baseline.
    To do it right, use one of Font's getLineMetrics methods and play around with ascent.

  • How to convert a string from upper case to lower case in FOX formula

    Hi Experts,
    How to convert a string from upper case to lower case in FOX formula?
    Thanks,
    Cheers!!!
    PANKAJ

    The last result.append( c ) should be:
    result.append( Character.toLowerCase(c) );

  • How to convert a string from lower case to upper case withour using transla

    Hi all,
    how to convert a string from lower case to upper case withour using translate,
    Thanks in Advance,
    Reddy

    Refer to this related thread
    Re: hi guys this very urgent please help

  • Converting a String to an array list

    Anyone know how i turn a string into an array list of characters?

    check out the java.lang.String API for the method toCharArray() for your answer.

  • How to convert a waveform signal into array of complex numbers

    How to convert a waveform signal into array of complex numbers.

    Hi Chaks,
    try this:
    (Get Waveform components, convert to complex DBL)
    Message Edited by GerdW on 01-28-2008 09:23 AM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    ToCDB.png ‏1 KB

  • How to convert a string data to a 1 d array

    Dear All,
    I am wondering if somebody help me.
    In the attached fle i have my program (in labview 8.6) which read temperature data and updates temperature during the time.
    I want to use the updated temperature in a calculation.  How can i get the new temperature which i think is in a string format and convert it to 1 d array?
    I tried but the number that i got from temperature was not the same temperature which is shonw in data section of the program.
    Could somebody please help me?
    Regards, 
    Solved!
    Go to Solution.
    Attachments:
    Readfiles[1].vi ‏152 KB

    You are not reading temperature, you are reading a binary file. You seem to be assuming string format but do you really know? No one here can tell since you did not attach the file If it is you would need to use one of the string conversion functions. And please, get rid of the Data local variable. You are already usin shift registers. Do the same with the data from the file.

  • How to get a string or byte array representation of an Image/BufferedImage?

    I have a java.awt.Image object that I want to transfer to a server application (.NET) through a http post request.
    To do that I would like to encode the Image to jpeg format and convert it to a string or byte array to be able to send it in a way that the receiver application (.NET) could handle. So, I've tried to do like this.
    private void send(Image image) {
        int width = image.getWidth(null);
        int height = image.getHeight(null);
        try {
            BufferedImage buffImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            ImageIcon imageIcon = new ImageIcon(image);
            ImageObserver observer = imageIcon.getImageObserver();
            buffImage.getGraphics().setColor(new Color(255, 255, 255));
            buffImage.getGraphics().fillRect(0, 0, width, height);
            buffImage.getGraphics().drawImage(imageIcon.getImage(), 0, 0, observer);
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            JPEGImageEncoder jpeg = JPEGCodec.createJPEGEncoder(stream);
            jpeg.encode(buffImage);
            URL url = new URL(/* my url... */);
            URLConnection connection = url.openConnection();
            String boundary = "--------" + Long.toHexString(System.currentTimeMillis());
            connection.setRequestProperty("method", "POST");
            connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
            String output = "--" + boundary + "\r\n"
                          + "Content-Disposition: form-data; name=\"myImage\"; filename=\"myFilename.jpg\"\r\n"
                          + "Content-Type: image/jpeg\r\n"
                          + "Content-Transfer-Encoding: base64\r\n\r\n"
                          + new String(stream.toByteArray())
                          + "\r\n--" + boundary + "--\r\n";
            connection.setDoOutput(true);
            connection.getOutputStream().write(output.getBytes());
            connection.connect();
        } catch {
    }This code works, but the image I get when I save it from the receiver application is distorted. The width and height is correct, but the content and colors are really weird. I tried to set different image types (first line inside the try-block), and this gave me different distorsions, but no image type gave me the correct image.
    Maybe I should say that I can display the original Image object on screen correctly.
    I also realized that the Image object is an instance of BufferedImage, so I thought I could skip the first six lines inside the try-block, but that doesn't help. This way I don't have to set the image type in the constructor, but the result still is color distorted.
    Any ideas on how to get from an Image/BufferedImage to a string or byte array representation of the image in jpeg format?

    Here you go:
      private static void send(BufferedImage image) throws Exception
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        ImageIO.write(image, "jpeg", byteArrayOutputStream);
        byte[] imageByteArray = byteArrayOutputStream.toByteArray();
        URL url = new URL("http://<host>:<port>");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setDoOutput(true);
        connection.setRequestMethod("POST");
        OutputStream outputStream = connection.getOutputStream();
        outputStream.write(imageByteArray, 0, imageByteArray.length);
        outputStream.close();
        connection.connect();
        // alternative to connect is to get & close the input stream
        // connection.getInputStream().close();
      }

  • Convert a string to an array of 16bit unsigned integers

    I have a string represented in hex format, how can I convert this to an array of 16 bit unsigned integers?
    I know I can use string to byte array to easily convert it to 8 but unsigned integers, is there a simple way for 16 bit unsigned integers?
    Solved!
    Go to Solution.

    hydzik wrote:
    I have a string represented in hex format, how can I convert this to an array of 16 bit unsigned integers?
    I know I can use string to byte array to easily convert it to 8 but unsigned integers, is there a simple way for 16 bit unsigned integers?
    While your description is somewhat vague and not very clear, I think the typecast solution from the previous poster may not be what you look for. You may more likely look for something along these lines:
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions
    Attachments:
    HexToU16.png ‏17 KB

  • XML: How to convert xml string into Node/Document

    I have a string in xml form.
    <name>
    <first/>
    <second/>
    </name>
    I want to convert this string into DOM Node or Document.
    How can I do this?
    Any help or pointer?
    TIA
    Sachin

    Try this :
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(new org.xml.sax.InputSource(new StringReader(strXml)));Hope this helps.

  • Help with how to convert a string to a number ??

    Hi All,
    I am having problem converting a string to number.
    Looks like my to_number function is not working.
    Help is very much appreciated.
    My query is below, and I know my problem is in my inner query.
    I am getting the following error:
    what am I doing wrong ? and how should I fix it.
    If there is a better approach, please share it.
    ORA-01722: invalid number
    01722. 00000 -  "invalid number"
    *Cause:   
    *Action:
    SELECT
        A.OBJECT_NAME,
        A.TIMESTAMP,
        A.SESSION_ID,
        A.REQUISITION_ID,
        TO_DATE(CUT(RR_PACE_FUNCTIONS.NAME(A.REQUISITION_ID),3,'.'),'YYYYMMDD') CSD,
        SUBSTR(SUBSTR(RR_PACE_FUNCTIONS.DESCRIPTION(A.REQUISITION_ID),9),1,30) COURSE_ID,
        A.WEEK_GROUP,
        A.APTITUDE_AREA,
        SUM(NVL(GTEP_ASGN,0)) GTEP_ASGN,
        SUM(NVL(AI_ASGN,0)) AI_ASGN,
        SUM(NVL(GTEP_ASGN,0) + NVL(AI_ASGN,0) ) BMT_ASGN
      FROM
        (SELECT OBJECT_NAME,
          SESSION_ID,
          TIMESTAMP,
          TO_NUMBER(FIELD1) REQUISITION_ID,  -- I believe here is the problem
          TO_NUMBER(FIELD2) WEEK_GROUP,     -- here as well
          SUBSTR(FIELD3,1,80) APTITUDE_AREA,
          TO_NUMBER(FIELD4) GTEP_ASGN,  -- here
          TO_NUMBER(FIELD5) AI_ASGN      -- here
        FROM RR_REPORT_QUEUES
        ) A
      GROUP BY OBJECT_NAME,
        TIMESTAMP,
        SESSION_ID,
        WEEK_GROUP,
        APTITUDE_AREA,
        REQUISITION_ID ;Many Thanks,

    Are you sure Field1, Field2, Field4 and Field5 contain a number information in all rows?
    If there is a non numeric String in your Field<x> columns in any row the error will occor.

  • [Oracle 8i] How to convert a string (time stamp) into a date?

    I'm having difficulty figuring out how to convert a time stamp string into a date (or possibly a number).
    The time stamp is 20 positions, character (NOT NULL, CHAR(20))
    in the format: YYYYMMDDHHMMSSUUUUUU
    where Y = Year, M = Month, D = Day, M = Minutes, S = Seconds, and U = Microseconds
    The reason I want to convert this is so that I can compare one time stamp to another (i.e. I want to be able to find the MIN(timestamp), MAX(timestamp), and do inequality comparisons).
    Is this at all possible?
    Thanks in advance for help on this!

    Hi,
    As Damorgan said, if all you want to do is find which is the earliest or latest, then you can just compare the strings: they happen to be in a format where that works.
    If you need to do other things, such as compare them to today's date, or see the difference between two of your rows in days, then you have to convert them to DATEs. (There's no point in converting them to NUMBERs).
    A new data type, TIMESTAMP, which handles fractions of a second, was introduced in Oracle 9.
    Since you're using Oracle 8 (according to your subject line), you either have to
    (1) ignore the microseconds, or
    (2) use a separate NUMBER column for the microseconds.
    Either way, use TO_DATE to convert the first 14 characters to a DATE:
    TO_DATE ( SUBSTR (txt, 1, 14)
            , 'YYYYMMDDHH24MISS'
            )where txt is your CHAR column.
    To convert the microseconds to a number (between 0 and 999999):
    TO_NUMBER (SUBSTR (txt, 15))

Maybe you are looking for

  • Creative cloud abo programme laden nicht

    Hallo! Sitze schon seit Tagen vorm MAC und versuche das Problem zu beheben, leider erfolglos! Hab mir fürs Studium Creative Cloud Student Version abonniert, jedoch kann ich keine Programme runterladen! Weder Photoshop noch Illustrator noch sonst ein

  • What is the use of Host in Technical system

    Hi experts, While creating Technical sytem what is the use of creating Host. while creating Business System we create Logical System.When we are creating for Sap system then there we give client logical sytem name,but while creating for third party s

  • Screen flashes and no alert sound

    Suddenly, with no changes to any settings that I'm aware of my screen has started flashing when it would usually play an alert sound. It's as though the Universal Access option is on to flash the screen, but it isn't. I've toggled this switch on and

  • How to implement this in Smartforms

    Hello, I have been given this information for what is wanted in a proforma invoice: Print a field for bankcode. Field name = tempBANKL. Logic: Select BANKS BANKL into tempBANKS tempBANKL from T012 where BUKRS = ls_bil_invoice-HD_ORG-COMP_CODE and HBK

  • Using variable values form parametrized URL in Customer Exit in i_step = 1

    Hello BW experts, I call a parametrized URL to a Web Template that has a Query with the variable VAR1: http://XXX?...&CMD=LDOC&template_id=TEMP1&VAR_NAME_1=VAR1&VAR_VALUE_EXT_1=2006 Then I try to access the value of VAR1 in i_step = 1 in the Customer