import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;


public class Test {
   public static void main(String[] args) {
     /**
     * mkdirs()创建多层目录,mkdir()创建单层目录
     * writeObject时才创建磁盘文件。
     * 若不创建文件,readObject出错。
     */

    String tablename = "hash1";
    File file = new File( "data/1/" + tablename);
     boolean mk=file.getParentFile().mkdir();
    System.out.println( "create:"+mk); //false
    mk=file.getParentFile().mkdirs();
    System.out.println( "create:"+mk); //true
    System.out.println( "file:" + file.getParentFile());

    ObjectOutputStream out = null;
     try {
      out = new ObjectOutputStream( new FileOutputStream(file));
      out.writeObject( new Integer(1));
      out.flush();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
       try {
         if (out != null)
          out.close();
      } catch (IOException e1) {
      }
    }
    ObjectInputStream oin = null;
     try{
      oin = new ObjectInputStream( new FileInputStream(file));
      Integer i=(Integer) oin.readObject();
      System.out.println( "i:"+i);
     }
     catch (Exception e)
     {
        e.printStackTrace();
     }
      finally{
         try{
            if (oin != null)
             oin.close();
        }
         catch (IOException e1){
        }
     }
  }
}