Computer Science Canada appendtext.java |
Author: | alpesh [ Thu Jan 22, 2004 9:07 am ] |
Post subject: | appendtext.java |
// append text in file import java.io.*; public class appendtext { public static void main(String args[]){ try { PrintStream out = new PrintStream(new AppendFileStream("myfile.txt")); out.print("A new line of text"); out.close(); } catch(Exception e) { System.out.println(e.toString()); } } } class AppendFileStream extends OutputStream { RandomAccessFile fd; public AppendFileStream(String file) throws IOException { fd = new RandomAccessFile(file,"rw"); fd.seek(fd.length()); } public void close() throws IOException { fd.close(); } public void write(byte[] b) throws IOException { fd.write(b); } public void write(byte[] b,int off,int len) throws IOException { fd.write(b,off,len); } public void write(int b) throws IOException { fd.write(b); } } |
Author: | shorthair [ Fri Jan 23, 2004 10:49 am ] |
Post subject: | |
WAnna tell me what it does, so i can meabe learn a few things ( not to flame im jsut interested ) as i start java next semester |
Author: | shorthair [ Sun Jan 25, 2004 6:03 pm ] |
Post subject: | |
i wonder if this guy will ever come back , i wana know what his programs do |