From 8bcd7f58acd38f5d5e1731f89be4a10a79d0fdb7 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 23 Jun 2012 22:44:40 +0530 Subject: scruf is "bzr"ed now. --- io/WriteFile.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 io/WriteFile.java (limited to 'io/WriteFile.java') 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 -- cgit v1.2.3