Java ObjectOutputStream Write saveObjectToFile(Object obj, String fileName)

Here you can find the source of saveObjectToFile(Object obj, String fileName)

Description

save Object To File

License

Open Source License

Declaration

public static void saveObjectToFile(Object obj, String fileName) 

Method Source Code


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

import java.io.*;

public class Main {
    public static void saveObjectToFile(Object obj, String fileName) {
        try (ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(fileName))) {
            stream.writeObject(obj);//  www  . ja  v  a 2  s .  c  o m
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. saveObject2FileImpl(final Serializable object, final File file)
  2. saveObjectInFile(String fileName, Object obj)
  3. saveObjectToFile(File file, Object object)
  4. saveObjectToFile(File thatFile, Object... thisObject)
  5. saveObjectToFile(final Object object, final String fileName)
  6. saveObjectToPath(T objectToSave, String pathToSaveTo)
  7. saveParameters()
  8. saveResultToStream(ObjectOutputStream oos, Object result)
  9. saveResultToStream(ObjectOutputStream oos, Object result)