Results 1 to 2 of 2
Thread: how to edit lines.
- 08-01-2007, 03:50 AM #1
Member
- Join Date
- Jul 2007
- Posts
- 18
- Rep Power
- 0
how to edit lines.
right now, im trying to edit the text file. however, all it does is overwrite over the original file. I want the string i add to be added to the original file. Is there someway i can do this?
For example, the original text says "hi". I want to add "how are you to it", so it would say "hi. how are you."
Code:(similar to before)
import java.io.*;
public class FileAccess {
public void displayFile(String f) throws IOException {
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
f = br.readLine();
while (f != null) {
System.out.println(f);
f = br.readLine();
}
br.close();
fr.close();
}
public void writeToFile(String outfile, String s) throws IOException {
FileOutputStream fs = new FileOutputStream(outfile);
PrintStream p = new PrintStream(fs);
p.println(s);
p.close();
fs.close();
}
}
thanks again.
ps. srry for all these questions
- 08-01-2007, 04:41 AM #2
Senior Member
- Join Date
- Jul 2007
- Posts
- 135
- Rep Power
- 0
Similar Threads
-
how can we remove blank lines from a .txt
By Camden in forum New To JavaReplies: 12Last Post: 07-29-2011, 01:38 PM -
How To Edit/Add JSP Pages in NetBeans IDE
By JavaForums in forum NetBeansReplies: 2Last Post: 02-17-2009, 11:14 AM -
How to get the count of all the lines in a file
By Java Tip in forum java.ioReplies: 0Last Post: 04-06-2008, 07:45 PM -
Can't edit JTextField after modal dialog
By JavaNerd in forum Java AppletsReplies: 0Last Post: 02-07-2008, 09:11 PM -
Doubt in edit and delete methods
By ai_2007 in forum Advanced JavaReplies: 3Last Post: 07-01-2007, 11:40 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks