Java ObjectOutputStream Write save(File f, T o)

Here you can find the source of save(File f, T o)

Description

save

License

Open Source License

Declaration

public static <T> void save(File f, T o) 

Method Source Code

//package com.java2s;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.ObjectOutputStream;

public class Main {
    public static <T> void save(File f, T o) {
        // TODO Auto-generated method stub

        ObjectOutputStream writer = null;
        try {//from  w  w w .  j a v a 2 s. c  om
            writer = new ObjectOutputStream(new FileOutputStream(f));

            writer.writeObject(o);

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        finally {

            if (writer != null) {

                try {
                    writer.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }

        }

    }
}

Related

  1. loadSerializableFile(File file)
  2. loadSerialized(File file)
  3. loadSerializedObject(String fileName)
  4. loadSerializedObjectWithExceptions(String fileName)
  5. loadTrace(File file)
  6. save(Object o)
  7. save(Object obj, String path)
  8. save(Serializable serialized, String filepath)
  9. save(String name, Serializable object)