package cn.javass.study.io;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
//文件的读写操作io流 public class FileStore { public static void writeFile(Mapdd map){ ObjectOutputStream out = null; try { out = new ObjectOutputStream( new BufferedOutputStream( new FileOutputStream("b.txt") ) ); out.writeObject(map); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ try { out.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public static Mapdd readFile(){ ObjectInputStream in = null; try { in = new ObjectInputStream( new BufferedInputStream( new FileInputStream("b.txt") ) ); Mapdd db = (Mapdd) in.readObject(); return db; } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ try { in.close(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; } }