Java FileWriter Write save2DArray(float[][] data, String filePath)

Here you can find the source of save2DArray(float[][] data, String filePath)

Description

save D Array

License

Open Source License

Declaration

public static void save2DArray(float[][] data, String filePath) 

Method Source Code

//package com.java2s;
/*//  ww  w .java 2s .  c  o  m
 * Copyright (c) 2008-2013 Maksim Khadkevich and Fondazione Bruno Kessler.
 *
 * This file is part of MART.
 * MART is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2, as published
 * by the Free Software Foundation.
 *
 * MART 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 MART; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

import java.io.FileWriter;
import java.io.IOException;

public class Main {
    public static void save2DArray(float[][] data, String filePath) {
        try {
            FileWriter writer = new FileWriter(filePath);
            for (int i = 0; i < data.length; i++) {
                for (int j = 0; j < data[0].length; j++) {
                    writer.write(String.format("%5.4f ", data[i][j]));
                }
                writer.write("\n");
            }
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. save(Map map, String path)
  2. save(String fileName, Object o)
  3. save(String fileName, String dataToSave)
  4. save(String modelo, String filename)
  5. save(String targetDir, String filename, String textToSave)
  6. save2File(String fileName, String content)
  7. save_array(double[] array, String fname)
  8. saveAllToFile(String filename, String... strings)
  9. saveArrayNames(int[] array, String[] names, String fname)