how to append the data in a file

Dear All,

i want to continously update one text file that is

in myfile.txt using java,

for example username:test:password:test

like wise how can i append this text with username and password to added in the next next line

[254 byte] By [sebas.navina] at [2007-11-27 10:25:39]
# 1

Create a FileWriter with the constructor shown below and then wrap it in a BufferedWriter.

http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileWriter.html#FileWriter(java.lang.String,%20boolean)

See this for more details...

http://www.exampledepot.com/egs/java.nio/WriteBuffer.html

Message was edited by:

_helloWorld_

_helloWorld_a at 2007-7-28 17:34:53 > top of Java-index,Java Essentials,Java Programming...
# 2

Thats easy enough to find, just google it.

blackmagea at 2007-7-28 17:34:53 > top of Java-index,Java Essentials,Java Programming...
# 3

Hi,

Thanks For your Help.one thing i have to clarify,

while i am appending the file

it writes in straight line

(ie) username:test:password:test:

when i append the file, FileWriter writer =new FileWriter("/myfile.txt",true);

writer.write("test /n");

writer.write("test /n");

it adds in the same line.(ie) username:test:password:test:test:test

how can we add in the new line while appending the file

sebas.navina at 2007-7-28 17:34:53 > top of Java-index,Java Essentials,Java Programming...
# 4

Take a look at this:

import java.io.BufferedWriter;

import java.io.FileWriter;

import java.io.IOException;

public class FileWrite {

public static void main(String[] args) throws IOException {

BufferedWriter br = new BufferedWriter(new FileWriter("C:\\temp.txt",true));

br.write("Hello");

br.newLine();

br.close();

}

}

_helloWorld_a at 2007-7-28 17:34:53 > top of Java-index,Java Essentials,Java Programming...
# 5

thank you very much _helloworld.

sebas.navina at 2007-7-28 17:34:53 > top of Java-index,Java Essentials,Java Programming...