Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read from a file

Status
Not open for further replies.

jl3574

Programmer
Jun 5, 2003
76
0
0
CA
how do i read from a file to a string?
i don't want to read one line at a time
buti want a whole text file apppend to a string...
 
If you haven't already done so then review the Sun tutorials at


as well as the java docs on java.io classes.

There are also many other tutorials on the internet dealing with just about every aspect of java.

There are a number of ways to do what you want to do but one way is to use a BufferedReader wrapped around a FileReader. Read a character at a time and append to a StringBuffer. Finally if you want it as a string then use the StringBuffer.toString() method.

Lentil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top