skip to main | skip to sidebar

java spring hibernate eclipse javascript linux sql WID WPS WESB SCA SDO

Just a collection of programming tips that I've accumulated in my head over the years, which I'm slowly putting into this blog, in case I forget them in future.

Wednesday, March 19, 2008

java: An algorithm for converting an array to comma delimited/separated string/value (e.g. csv)

StringBuilder sb = new StringBuilder();

Long[] array = {new Long("1"), new Long("2"), new Long("3")};

for (int i = 0; i < array.length(); i++)
{
   if (i > 0) 
   {
       sb.append(", ");
   }

   sb.append(array[i]);
}

System.out.println(sb.toString());

//output: 1, 2, 3
Posted by zeitgravity at 19.3.08
Labels: java

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

About Me

zeitgravity
View my complete profile

Labels

  • eclipse
  • java
  • javascript
  • linux
  • regex
  • spring
  • sql
  • Web Service
  • Websphere Application Server
  • Websphere Integration Developer
  • Websphere Process Server

Blog Archive

  • ►  2015 (1)
    • ►  February (1)
  • ►  2009 (1)
    • ►  July (1)
  • ▼  2008 (17)
    • ▼  March (8)
      • java: An algorithm for converting an array to comm...
      • java: How to convert String array to Long array
      • java: How to put checkboxes in DisplayTag using St...
      • javascript: How to select/deselect checkboxes
      • java: How to get DisplayTag sorting URL to work in...
      • java: How to convert a String ArrayList into Strin...
      • java: The difference between the HTML comment &lt!...
      • java: Why Log4J's Logger should be declared static...
    • ►  February (5)
    • ►  January (4)
  • ►  2007 (2)
    • ►  December (1)
    • ►  October (1)
  • ►  2006 (7)
    • ►  October (4)
    • ►  January (3)