Write text file to string?

Could anyone tell me how to write a text file into a String with the text file created yet .
[99 byte] By [Shonea] at [2007-11-26 18:50:08]
# 1
Do you mean read a text file into a String? Take a look at the Scanner class.
CaptainMorgan08a at 2007-7-9 6:24:10 > top of Java-index,Java Essentials,Java Programming...
# 2
Sorry, I mean read a text file into a String.Thanks!
Shonea at 2007-7-9 6:24:10 > top of Java-index,Java Essentials,Java Programming...
# 3

Have a look at this and see what you can understand. It's an old code which i wrote when i was learning java. I don't think i have used any coding conventions(I haven't given it a peep now).

import java.io.*;

class io6

{

public static void main(String args[]) throws Exception

{

BufferedReader br=new BufferedReader(new FileReader("G:/java files/io5.java"));

String str=null;

while((str=br.readLine())!=null)

{

System.out.println(str);

Thread.sleep(75);

}

}

}

qUesT_foR_knOwLeDgea at 2007-7-9 6:24:10 > top of Java-index,Java Essentials,Java Programming...
# 4
> ... I don't think i have used any coding> conventions(I haven't given it a peep now).You should do so (for your own benefit and your project-colleagues): http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
prometheuzza at 2007-7-9 6:24:10 > top of Java-index,Java Essentials,Java Programming...
# 5

> > ... I don't think i have used any coding

> > conventions(I haven't given it a peep now).

>

> You should do so (for your own benefit and your

> project-colleagues):

> http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc

> .html

I won't be needing this. That was a long time back. Then i never knew what were the coding conventions. And the example i produced was when i was still learning java(didn't know what were the coding conventions then) and the same example i have picked and posted. There's a difference between now and then both in terms of time and what i have learnt and coding conventions is one thing that i learnt.

qUesT_foR_knOwLeDgea at 2007-7-9 6:24:10 > top of Java-index,Java Essentials,Java Programming...
# 6

> ...

> I won't be needing this. That was a long time back.

> Then i never knew what were the coding conventions.

> And the example i produced was when i was still

> learning java(didn't know what were the coding

> conventions then) and the same example i have picked

> and posted. There's a difference between now and then

> both in terms of time and what i have learnt and

> coding conventions is one thing that i learnt.

Then try to assist the OP by posting code that is consistent with Java's code conventions.

prometheuzza at 2007-7-9 6:24:10 > top of Java-index,Java Essentials,Java Programming...
# 7

> Then try to assist the OP by posting code that is

> consistent with Java's code conventions.

I was a bit lazy to edit the names and post and thats the reason why i told him that i haven't used coding conventions in that code. The op anyways wants to know how to carry out the task and the code should give him/her the direction needed.

qUesT_foR_knOwLeDgea at 2007-7-9 6:24:10 > top of Java-index,Java Essentials,Java Programming...
# 8
> I was a bit lazy> ...Then we agree on something after all!
prometheuzza at 2007-7-9 6:24:10 > top of Java-index,Java Essentials,Java Programming...