Java Utililty Methods ObjectOutputStream Write

List of utility methods to do ObjectOutputStream Write

Description

The list of methods to do ObjectOutputStream Write are organized into topic(s).

Method

voidsaveObject(Object object, File file)
Saves a raw Object to a file.
if (!file.exists()) {
    file.getParentFile().mkdirs();
final ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
oos.writeObject(object);
oos.close();
voidsaveObject(Object object, String filename)
Stores a Serializable Object.
saveObject(object, new FileOutputStream(filename));
voidsaveObject(Object object, String filename)
Save Object - save 'object' into file 'filename'.
FileOutputStream fout = new FileOutputStream(filename);
ObjectOutputStream oos = new ObjectOutputStream(fout);
oos.writeObject(object);
oos.flush();
oos.close();
voidsaveObject(Object saveObject, File path)

Saves an Object to a file (can only be used on serializable Objects)

ObjectOutputStream o = new ObjectOutputStream(new FileOutputStream(path, false));
o.writeObject(saveObject);
o.close();
voidsaveObject(Serializable obj, String url)
Saves an Serializable Object to the hard disk.
try {
    FileOutputStream fOut = new FileOutputStream(url);
    ObjectOutputStream objOut = new ObjectOutputStream(fOut);
    objOut.writeObject(obj);
} catch (Exception e) {
    System.err.println(e.getMessage());
voidsaveObject(String filename, Object obj)
save Object
FileOutputStream fos = new FileOutputStream(filename);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(obj);
oos.flush();
oos.close();
fos.close();
booleansaveObject(String filename, Object obj)
save Object
try {
    FileOutputStream fileOut = new FileOutputStream(filename);
    ObjectOutputStream out = new ObjectOutputStream(fileOut);
    out.writeObject(obj);
    out.close();
    fileOut.close();
    return true;
} catch (FileNotFoundException e) {
...
voidsaveObject(String filePath, Serializable obj)
save Object
FileOutputStream fos = null;
ObjectOutputStream out = null;
try {
    fos = new FileOutputStream(filePath);
    out = new ObjectOutputStream(fos);
    out.writeObject(obj);
    out.close();
} catch (IOException ex) {
...
voidsaveObject(T object, File file, boolean use_compression)
save Object
OutputStream stream;
FileOutputStream fout = new FileOutputStream(file);
if (use_compression) {
    stream = new GZIPOutputStream(fout);
} else {
    stream = fout;
ObjectOutputStream fstream = new ObjectOutputStream(stream);
...
voidsaveObject2File(final Serializable object, final File file)
save Object File
try {
    saveObject2FileImpl(object, file);
} catch (final Exception _exception) {
    throw new RuntimeException(
            "Problems saving object [" + object + "] to file [" + file + "]: " + _exception.getMessage(),
            _exception);