2 Replies Latest reply: Feb 14, 2007 1:22 PM by 807599 RSS

    Converting String[] to string and vica versa

    807599
      Hi

      I have found an efficient way to convert a string[] to a string:
      public static void main( String[] args ) {
                arrayToString(args," ");
                 }
      
          public static void arrayToString(String[] a, String separator) {
            
              StringBuffer result = new StringBuffer();
              if (a.length > 0) {
                  result.append(a[0]);
                  for (int i=1; i<a.length; i++) {
                      result.append(separator);
                      result.append(a);
      }
      }
      }
      Could someone tell me an efficient way to convert the string back to string[]

      Thanks