00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 package com.meapsoft;
00024
00025 import java.io.BufferedWriter;
00026 import java.io.FileWriter;
00027 import java.io.IOException;
00028 import java.io.Serializable;
00029 import java.io.StringWriter;
00030 import java.io.Writer;
00031
00038 public abstract class MEAPFile implements Serializable
00039 {
00040 public String filename;
00041
00042
00043 public boolean haveReadFile = false;
00044
00045
00046 public boolean haveWrittenFile = false;
00047
00051 public abstract void readFile() throws IOException, ParserException;
00052
00056 protected abstract void write(Writer w) throws IOException;
00057
00061 public void writeFile() throws IOException
00062 {
00063 writeFile(filename);
00064 }
00065
00069 public void writeFile(String fn) throws IOException
00070 {
00071 writeFile(fn, false);
00072 }
00073
00079 public void writeFile(String fn, boolean append) throws IOException
00080 {
00081 if(fn == null)
00082 fn = filename;
00083
00084
00085 BufferedWriter out = new BufferedWriter(new FileWriter(fn, append));
00086 write(out);
00087 out.close();
00088
00089 haveWrittenFile = true;
00090 }
00091
00096 public String toString()
00097 {
00098 StringWriter s = new StringWriter();
00099
00100 try { write(s); }
00101
00102 catch(IOException e) {;}
00103
00104 return s.toString();
00105 }
00106 }