Java ObjectOutputStream Write loadData(HashMap data, String filename)

Here you can find the source of loadData(HashMap data, String filename)

Description

load Data

License

LGPL

Declaration

@SuppressWarnings("rawtypes")
    public static HashMap loadData(HashMap data, String filename) 

Method Source Code

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

import java.io.FileInputStream;

import java.io.IOException;
import java.io.ObjectInputStream;

import java.util.HashMap;

public class Main {
    @SuppressWarnings("rawtypes")
    public static HashMap loadData(HashMap data, String filename) {
        try {//from  w ww. j a  v  a2s .co m
            data = (HashMap) readObject(filename);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return data;
    }

    private static Object readObject(String filename) throws IOException, ClassNotFoundException {

        FileInputStream fileIn = new FileInputStream(filename);
        ObjectInputStream in = new ObjectInputStream(fileIn);
        Object data = in.readObject();
        in.close();
        fileIn.close();
        return data;

    }
}

Related

  1. load(String filename)
  2. load(String name, Class resultClass)
  3. load(String path)
  4. loadAllPlaying(String path)
  5. loadData(Class expectedClass, String filename)
  6. loadGZipObject(File file)
  7. LoadMatFromFile(double[] mat, String filename)
  8. loadObj(String file)
  9. loadSerializableFile(File file)