Java Write String to File writeFile(String filename, Object object)

Here you can find the source of writeFile(String filename, Object object)

Description

write File

License

Apache License

Declaration

public static void writeFile(String filename, Object object) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import java.io.ObjectOutputStream;

public class Main {
    public static void writeFile(String filename, Object object) {
        try {//from ww w. j  a  v  a 2  s.c om
            FileOutputStream fout = new FileOutputStream(filename);
            ObjectOutputStream oos = new ObjectOutputStream(fout);
            oos.writeObject(object);
            oos.close();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

Related

  1. writeFile(String contents, String fileName)
  2. writeFile(String data, File file)
  3. writeFile(String data, File tar)
  4. writeFile(String datafile, String filePath)
  5. writeFile(String destination, byte[] data, boolean append)
  6. writeFile(String fileName, String content)
  7. writeFile(String filename, String content)
  8. writeFile(String filename, String content)
  9. writeFile(String filename, String content)