diff options
author | rsiddharth <rsiddharth@ninthfloor.org> | 2012-06-23 22:44:40 +0530 |
---|---|---|
committer | rsiddharth <rsiddharth@ninthfloor.org> | 2012-06-23 22:44:40 +0530 |
commit | 8bcd7f58acd38f5d5e1731f89be4a10a79d0fdb7 (patch) | |
tree | 6c1d4dfc97d77230ecf95d4e0f8b4fe1cde5b739 /io/WriteFile.java |
scruf is "bzr"ed now.
Diffstat (limited to 'io/WriteFile.java')
-rw-r--r-- | io/WriteFile.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/io/WriteFile.java b/io/WriteFile.java new file mode 100644 index 0000000..454b567 --- /dev/null +++ b/io/WriteFile.java @@ -0,0 +1,33 @@ +package scruf.io; + +import java.io.*; + +public class WriteFile { + private File outputFile; + private String content; + public WriteFile(File outputFile, String content) { + this.outputFile = outputFile.getAbsoluteFile(); + this.content = content; + } + public void write() { + try { + System.out.println("Writing..."+outputFile.getName()); + BufferedWriter bwriter = new BufferedWriter + (new FileWriter(outputFile)); + // write content to file. + bwriter.write(content); + bwriter.close(); + }catch(IOException e) { + System.err.println("Error occured while writing"+ + " file : "+outputFile); + } + } + public void append() { + StringBuilder sbuilder = new StringBuilder( + new ReadFile(outputFile).getContent()); + sbuilder.append(content); + // new content + content = sbuilder.toString(); + write(); + } +}
\ No newline at end of file |