public void writeObject(HashMap map) {
try {
FileOutputStream outStream = new FileOutputStream("E:/1.txt");
ObjectOutputStream objectOutputStream = new ObjectOutputStream(outStream);
objectOutputStream.writeObject(map);
outStream.close();
System.out.println("successful");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
@SuppressWarnings("unchecked")
public HashMap,?> readObject(File file){
FileInputStream freader;
try {
freader = new FileInputStream(file);
ObjectInputStream objectInputStream = new ObjectInputStream(freader);
HashMap map = new HashMap();
map = (HashMap) objectInputStream.readObject();
return map;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}