Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 appendtext.java
Index -> Programming, Java -> Java Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
alpesh




PostPosted: 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);
}
}
Sponsor
Sponsor
Sponsor
sponsor
shorthair




PostPosted: Fri Jan 23, 2004 10:49 am   Post subject: (No 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
shorthair




PostPosted: Sun Jan 25, 2004 6:03 pm   Post subject: (No subject)

i wonder if this guy will ever come back , i wana know what his programs do
Display posts from previous:   
   Index -> Programming, Java -> Java Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: