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
00041 public String filename;
00042 public boolean haveReadFile = false;
00043 public boolean haveWrittenFile = false;
00044
00048 public abstract void readFile() throws IOException, ParserException;
00049
00053 protected abstract void write(Writer w) throws IOException;
00054
00058 public void writeFile() throws IOException
00059 {
00060 writeFile(filename);
00061 }
00062
00066 public void writeFile(String fn) throws IOException
00067 {
00068 writeFile(fn, false);
00069 }
00070
00076 public void writeFile(String fn, boolean append) throws IOException
00077 {
00078 if(fn == null)
00079 fn = filename;
00080
00081
00082 BufferedWriter out = new BufferedWriter(new FileWriter(fn, append));
00083 write(out);
00084 out.close();
00085
00086 haveWrittenFile = true;
00087 }
00088
00093 public String toString()
00094 {
00095 StringWriter s = new StringWriter();
00096
00097 try { write(s); }
00098
00099 catch(IOException e) {;}
00100
00101 return s.toString();
00102 }
00103 }