Java FileWriter Write saveData(Map> data, String file)

Here you can find the source of saveData(Map> data, String file)

Description

save Data

License

Open Source License

Declaration

public static void saveData(Map<String, Map<String, Double>> data, String file) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedWriter;
import java.io.File;

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

import java.util.Map;

public class Main {
    public static void saveData(Map<String, Map<String, Double>> data, String file) {
        //Map<String, OntologyUtils.Term> utils = new OntologyUtils().getGOHierarchy();
        try {// w w  w  . j ava2  s .c o m
            File f = new File(file);
            if (!f.exists()) {
                f.createNewFile();
            }
            FileWriter fw = new FileWriter(f.getAbsoluteFile());
            BufferedWriter bw = new BufferedWriter(fw);
            //for(String s:mapping.keySet()){
            //    bw.write("\t" + s);
            //}
            bw.newLine();
            boolean column = false;
            for (String c : data.keySet()) {
                if (!column) {
                    for (String g : data.get(c).keySet()) {
                        bw.write("\t" + g);
                    }
                    column = true;
                    bw.newLine();
                }

                bw.write(c);
                for (String g : data.get(c).keySet()) {
                    //System.out.println(c + "\t" + g + "\t" + mapping.get(c).get(g));
                    bw.write("\t" + data.get(c).get(g));
                }
                bw.newLine();

            }
            bw.close();
        } catch (IOException io) {
        }

    }
}

Related

  1. saveCCS(Map contributionScore, String diseaseState, String file)
  2. saveColumn(int[] density, String filename)
  3. saveConfig(File conf, Map data)
  4. saveContent(String context, String filename)
  5. saveData(Map> data, File file)
  6. saveData(String fileName, double totalTime, int[] resultSubset)
  7. saveDictionary(String fileName, Map values)
  8. saveDotGraph(final String dotGraph, final File outputDirectory)
  9. saveDoubleArray2File(Double[] doubleArray, String fileName)