存 TextFile outfile = new TextFile(); outfile.add("# Created at " + (new Date())); outfile.add(""); outfile.add("_NUM3D: "+num3d); outfile.add("_NUM4D: "+num4d);
取:
public void load(String filename) { try { this.setFileName(filename); TextFile infile = new TextFile(filename); String line = new String(); for (int i = 0; i < infile.size(); i++) { line = (String) infile.get(i); if (line.matches("^[ \t\f]*(#+).*") || line.matches("^[ \t\f]*")) { continue; } line = line.trim(); String flag = (line.split("[ \t\f\r\n]+"))[0]; if (flag.equals("_NUM3D: ")) { String str = (line.split("_NUM3D: "))[1]; str.trim(); this.num3d = Integer.parseInt(str); System.out.println(num3d); continue; }