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.

Similar Messages

  • 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 some caracteres of a String in bold characteres?? hELPME

    How can i convert some caracteres of a String in bold caracteres?? hELPME
    I have a JList and a DefaultListModel of Strings. So, i have many key words like "proccess", "if", "fi" that i want these characteres in bold.

    How i can use HTML in java to change a String to bold?
    example
    String str = "channel ";
    str = <b>str</b>;
    like this? syntax error =/

  • How can i convert JMS TextMessage into a String

    Please tell me,How can i convert A JMS TextMessage into a String

    http://java.sun.com/javaee/5/docs/api/javax/jms/TextMessage.html#getText()

  • How can I convert/read out from a string Hex (8-bit), the bit 0 length 1

    How can I convert/read out from Hex (8-bit), the bit 0 length 1 (string subset!!??) and convert it to decimal.
    With respect to one complement and two complement ?

    Just like Jeff, purely guessing here.
    It almost sounds like you just need to Read from Binary File?
    AND the 8-bit number with 1?
    Need more details.  What exactly do you have to start with?  What exactly are you trying to get out of it?  Examples help.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How can I convert a Waveform to a String-For​mat?

    Hello,
    I write with "SQL-Execute.vi" datas to an Access-file. The "SQL-Execute.vi" needs a statement in String Format. And that is my problem. My source-datas (that I want to save to Access) are Waveforms. How can I convert the Waveform datas to a String Format?
    Thanks for help!

    Wire the waveform to the Get waveform componants function...from that you get t0, delta t and the sample values. Now you can generate whatever string you want based on that information...
    You could e.g. wire the Y array to a for-loop in which you calculate the time of each sample by taking t0 and adding delta t multiplied with the array index, then you could convert the Y value and the time to strings using the seconds to time string and number to fractional string functions...etc etc...
    MTO

  • How can I convert date infomation to a string just includes the date not th

    I just want the date like Thu 08, july 2004 but not the exact time.
    how can I do that.

    The prior code produces a date formatted as Jul 7, 2004
    To get Wed 07, July 2004, try this minor modification:
    import java.text.DateFormat;
    import java.util.Date;
    import java.text.SimpleDateFormat;
    DateFormat format = new SimpleDateFormat("EEE dd, MMMM yyyy");
    Date mydate = new Date();
    String str = format.format(mydate);
    System.out.println(str);

  • HOW can I convert int value char TO String

    I am trying to study Java by books, but sometimes it is quite difficult to find answers even to simple questions...
    I am writing a program that analyzes a Chinese text in Unicode. What I get from the text is CHAR int value (in decimals), and now I need to find them in another text file (with RegEx). But I can't find a way how to convert an INT value of a char into a String.
    Could you help me?
    Thank you in advance.

    You are confusing matters a bit. A char is a char is a char, no matter
    how you represent it. Have a look at this:char a= 'A';
    char b= 65;Both a and b have the same value. The representation of that value
    can be 'A' or 65 or even (char)('B'-1), because the decimal representation
    of 'B' is 66. Note the funny construct (char)(...). This construct casts
    the value ... back to the char type. Java performs all non-fraction
    arithmetic using four byte integers. The cast transforms it back to
    a two byte char type.
    Strings are just concatenations of zero or more chars. the charAt(i)
    method returns you the i-th char in a string. Have a look:String s= "AB";
    char a= 'A';
    char b= (char)(a+1);
    if (a == s.charAt(0)) System.out.println("yep");
    if (b == s.charAt(1)) System.out.println("yep");This piece of code prints "yep" two times. If you want to compare two
    Strings instead, you have to do this:String s= "AB";
    char a= 'A';
    char b= 'B';
    String t= ""+a+b;
    if (s.equals(t)) System.out.println("yep");Note the 'equals' method instead of the '==' operator. Also note that
    string t was constructed using those two chars. The above was a
    shorthand of something like this:StringBuffer sb= new StringBuffer("");
    sb.append(a);
    sb.append(b);
    String t= sb.toString();This is all handled by the compiler, for now, you can simply use the '+'
    operator if you want to append a char to a string. Note that it is not
    very efficient, but it'll do for now.
    Does this get your started?
    kind regards,
    Jos

  • How can i convert if the date in string format

    String lFstr = (String) pReq.getParameter("FND");
    String lTstr = (String) pReq.getParameter("TND");
    String lLstr = (String) pReq.getParameter("LWD");
    System.out.println(lFstr + " " + lTstr + " " + lLstr);
    //DateFormat ds = DateFormat.getDateInstance();
    DateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
    Date lFdate = null;
    Date lTdate = null;
    Date lLdate = null;
    try {
    lFdate = dateFormatter.parse(lFstr);
    lTdate = dateFormatter.parse(lTstr);
    lLdate = dateFormatter.parse(lLstr);
    } catch (Exception e) {
    System.out.println(lFdate+" "+lTdate+" "+lLdate);
    i am getting the values from request parameters at that time it is giving values.
    after convertion of string to date it is giving the null value what is wrong in this code

    It might have thrown an exception. Try printing the stack trace in the catch block.

  • How can I convert a tab to a String

    Hello,
    I want to read a file, and check if in some place from the text there is a tab there, in case there exist one, repmplace for <tab8> or something like that.
    I have the following.
    import java.io.*;
    import java.util.*;
    public class Expander {
      // other declarations ...
      public static void expand(String[] args) {
    //    BufferedWriter br = new BufferedReader();
        try{
          if(args[0].equals("-v")){
            System.out.println("Expander Version 1.0\nCopyright (C)");
          if(args[0].equals("-h")){
            System.out.println("");
            System.out.println("Usage: java Expander [OPTION] ... [FILE] ...");
            System.out.println("Convert tabs in each FILE to spaces, writing to standard output.");
            System.out.println("Without FILE or with FILE = -, read from standard input.");
            System.out.println("");
            System.out.println("-i    do not convert TABs after non-whitespace.");
            System.out.println("-i=N  have tabs (positive) N spaces apart, not the default 8.");
            System.out.println("-h    display this help message and exit.");
            System.out.println("-v    display version information and exit.");
          if(args[0].equals("-i")){
            BufferedReader in = new BufferedReader(new FileReader(args[1]));
            String tempLine;
            while((tempLine = in.readLine()) != null){
              String temp = check(tempLine);
              System.out.println(temp);
              writeNew(temp,"1"+args[1]);
          else
            System.err.println("Command not Accepted, please check -h for more help");
        catch(IOException e){System.out.println(e);}
        catch(NoClassDefFoundError i){System.out.println(i);System.exit(0);}
      }// closes readLoadData
      public static String check(String line){
        if ( line.equals("\t") )
          return "<TAB8>";
        else
          return line;
      public static void writeNew(String line, String args){
        String name = args+".txt";
        try
          BufferedWriter out = new BufferedWriter(new FileWriter(name, true));
          PrintWriter fw = new PrintWriter(out);
          fw.print(line);
          out.close();
        catch(IOException e)
        { System.out.println(e);}
      public static void main(String[] args) {
        Expander.expand(args);
    }any ideas?
    Tahnks =)

    Hi,
    I guess the best way is to use regular expressions (must use SDK 1.4.1 or higher):
    Add the line:
    import java.util.regex.*;
    and use one of the methods:
    //Regex method to replace all \\t by <tab>
    public String replaceTabs1(String line, String tab) {
    Matcher matcher = Pattern.compile("\t").matcher(line);
    tab = matcher.replaceAll("<tab>");
    return line;
    //Regex method to replace \\t by <tab> one by one
    public String replaceTabs2(String line) {
    Matcher matcher = Pattern.compile("\t").matcher(line);
    while(matcher.find()){
    line = matcher.replaceFirst("<tab>");
    return line;
    Or, use more general method to find and replace any string by any other string in your file
    public String replaceText(String source, String find, String replace) {
    Matcher matcher = Pattern.compile(find).matcher(source);
    source = matcher.replaceAll(replace);
    return source;
    Hope it will work,
    VM

  • How can I convert an InputStream to a FileInputStream ???

    How can I convert an InputStream to a FileInputStream ???

    Thanks for you reply, however, I am still stuck.
    I am trying to convert my application (which runs smoothly) to a signed applet. The following is the original (application) code:
    private void loadConfig() {
    String fileName = "resources/groupconfig";
    File name = new File(fileName);
    if(name.isFile()) {
    try {
         ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileName));
         pAndGConfig = (PAGroupsConfig)in.readObject();
         in.close();
         return;
    } catch(ClassNotFoundException e) {
         System.err.println("++ERROR: "+e);
    } catch(IOException e) {
         System.err.println("++ERROR: "+e);
    System.out.println("Can't find file: " + fileName);
    Because all code and resources now reside in a Jar file (for the signed applet), I must use the following line to access the resources:
    InputStream is = this.getClass().getResourceAsStream(fileName);
    I then need to convert the 'InputStream' to 'ObjectInputStream' or 'FileInputStream' so that I can work with it.
    I would be very grateful if you could help shed some light on the matter - Cobram

  • How can I convert an OVM vm (.img) to VDI (virtualbox)?

    Hi,
    how can I convert an OVM vm (.img) to VDI (virtualbox)?
    Is .img format a raw image? If yes can I use "VBoxManage convertdd" to convert from .img to vdi?
    tnx & regards,
    S.

    Hi,
    "VBoxManage convertdd" solved.
    Regards,
    S.

  • How can I convert an AUDIO MPEG-4 to an MPEG3 format? I need it for a Powerpoint Presentation

    How can I convert an AUDIO  MPEG-4 to another type of file, such as MPEG3  or mp3

    Use Handbrake.
    You can download it for free from this site:
    http://www.macupdate.com/info.php/id/12987/handbrake
    Good luck

  • I want to remove the monitor from my 17" Macbook Pro 2008 to use as an external for my Macbook Pro 15" 2012. How can I convert lvds to Thunderbolt and power the monitor?

    I want to remove the monitor from my 17" Macbook Pro 2008 to use as an external for my Macbook Pro 15" 2012. How can I convert lvds to Thunderbolt and power the monitor?

    It's almost impossible.  The new iMacs have a Target Display Mode, but it's built to do that.  Without ripping your screen out, finding an acceptable power supply, frame, and whatever electronics to convert a Thunderbolt signal to the screen, the cost will be much larger than buying a cheaper HiDef monitor that runs with an HDMI to Thunderbolt cable to your MacBook 15.  In fact, you can sell your 17" MBP for a lot of money, unless it's broken or something, buying you a really sweet monitor.
    By the way, I found your answer by searching this forum.  I would suggest using the search function here in the futuere.

  • How can I convert an array off byte into an Object ?

    Hi folks...
    I�m developing an application that comunicates a PDA and a computer via Wi-Fi. I�m using a DataStream ( Input and Output ) to receive / send information from / to the computer. Most off the data received from him is in the byte[] type...
    How can I convert an array off byte ( byte[] ) into an Object using MIDP 2.0 / CLDC 1.1 ?
    I found on the web 2 functions that made this... but it uses a ObjectOutputStream and ObjectInputStream classes that is not provided by the J2ME plataform...
    How can I do this ?
    Waiting answers
    Rodrigo Kerkhoff

    There are no ObjectOutputStream and ObjectInputStream classes in CLDC. You must know what you are writing to and reading from the DataStream. You should write the primitives like int, String to the DataOutputstream at one end and read those in exactly the same sequence at the outher end using readInt(), readUTF() methods.

Maybe you are looking for

  • Smooth Cam on interlaced video

    I am trying to use the Smooth Cam node on video shot at 29 frames a second. I have had good luck in the past using 24 frame footage shot using the P2 cards for the Panasonic HVX-200 but this time I am using footage shot on miniDV. The problem is ther

  • Correction to Dodge Burn T00l

    I' a newbie to photoshop elements (v9). In Philip Andrews book "Adobe Photoshop Elements 9 for Photographers" he covers the Dodge and Burn tools. where can  these tools be found? This superseeds previous message on same subject. thanks bluemustang

  • Hi!  I wonder if you folks could help me out please.

    I have an imac with a 300gig hard drive. My external hard drive died on me so I bought a western digital My book Studio Edition 500gig drive from the Apple Store. The assistant said it would be big enough for me However, my friend has just told me th

  • E71 firmware upgrade failed and mobile software co...

    I recently purchased a new E71 and on the same day I run the "Phone software upgrade". It took around 2-3 hours to download and upgrade the phone. I saw it was updating to 3.x framework from 2.x. When I see after 2-3 hours what I saw that screen was

  • Need help with the following.

    Hi everybody.., can anyone plz check the following code and tell that how to end the exception after "raise form_trigger_failure and end if;" thanks in advance. DECLARE v_amount number(15,2); v_old_amount number(15,2); f_number varchar2(10); BEGIN se