Java Array to String arrayToString(String format, double[] array)

Here you can find the source of arrayToString(String format, double[] array)

Description

array To String

License

Open Source License

Declaration

public static String arrayToString(String format, double[] array) 

Method Source Code

//package com.java2s;
/*Copyright (C) 2012 Lars Andersen, Tormund S. Haus.
larsan@stud.ntnu.no/*from   w  w  w .j  a  v  a  2  s  .com*/
tormunds@stud.ntnu.no
    
EASY is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
     
EASY is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
     
You should have received a copy of the GNU General Public License
along with EASY.  If not, see <http://www.gnu.org/licenses/>.*/

import java.io.PrintWriter;
import java.io.StringWriter;

public class Main {
    public static String arrayToString(String format, double[] array) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        pw.print("[");
        if (array.length > 0)
            pw.printf(format, array[0]);
        for (int i = 1; i < array.length; i++) {
            pw.print(", ");
            pw.printf(format, array[i]);
        }
        pw.print("]");
        return sw.toString();
    }
}

Related

  1. arrayToString(Object[] objs, boolean stripPackageNames)
  2. arrayToString(Object[] objs, String separator)
  3. ArrayToString(Object[] row, StringBuilder sbf)
  4. arrayToString(Object[] subject)
  5. arrayToString(String array[], String separator)
  6. arrayToString(String in[])
  7. arrayToString(String values[])
  8. arrayToString(String[] a, String delim)
  9. arrayToString(String[] a, String separator)