public void write(File f) { try { ObjectOutputStream oos = new ObjectOutputStream( new FileOutputStream(f)); oos.writeObject(this); oos.close(); } catch (IOException e) { System.err.println("Exception writing file " + f + ": " + e); } } public CRF read(File f) { try { ObjectInputStream ois = new ObjectInputStream( new FileInputStream(f)); CRF crf = (CRF) ois.readObject(); ois.close(); return crf; } catch (Exception e) { System.err.println("Exception read file " + f + ": " + e); return null; } } crf.write(new File("web.model")); CRF crf1 = crf.read(new File("web.model"));