Java FileWriter Write save(String fileName, Object o)

Here you can find the source of save(String fileName, Object o)

Description

save

License

Open Source License

Declaration

public static void save(String fileName, Object o) throws IOException 

Method Source Code

//package com.java2s;

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

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class Main {
    public static void save(String fileName, Object o) throws IOException {
        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        try (FileWriter out = new FileWriter(fileName);) {
            out.write(gson.toJson(o));/*w ww .j av  a 2  s.  com*/
        }
    }
}

Related

  1. save(File file, String text)
  2. save(File pFile, String pString)
  3. save(final String content, final String file)
  4. save(List list, String REPO)
  5. save(Map map, String path)
  6. save(String fileName, String dataToSave)
  7. save(String modelo, String filename)
  8. save(String targetDir, String filename, String textToSave)
  9. save2DArray(float[][] data, String filePath)