Java FileOutputStream Create writeFile(String filePathName, Object obj)

Here you can find the source of writeFile(String filePathName, Object obj)

Description

write File

License

Open Source License

Declaration

public static void writeFile(String filePathName, Object obj) 

Method Source Code


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

import java.io.*;

public class Main {

    public static void writeFile(String filePathName, Object obj) {
        ObjectOutputStream oout = null;
        File file = new File(filePathName);
        try {/*www. j  ava  2 s .  com*/
            if (!file.exists()) {
                file.createNewFile();
            }
            oout = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)));

            oout.writeObject(obj);
        } catch (Exception err) {
            err.printStackTrace();
        } finally {
            try {
                oout.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. writeFile(String file, byte[]... data)
  2. writeFile(String fileName)
  3. writeFile(String fileOutput, byte[] data)
  4. writeFile(String filePath, byte[] bytes)
  5. writeFile(String filePath, Object obj)
  6. writeFile(String p_filename, String p_buffer)
  7. writeFile(String path, byte[] contents)
  8. writeFile(String path, byte[] data)
  9. writeFile(String path, Properties store, String comment)