This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Is there an efficient way to read a text file into a string? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Is there an efficient way to read a text file into a string?" Watch "Is there an efficient way to read a text file into a string?" New topic
Author

Is there an efficient way to read a text file into a string?

Tong Chen
Ranch Hand

Joined: Apr 26, 2002
Posts: 1011
Hi,
Is there an efficient way to read a text file into a string? or anybody can give me a sample code?
Thanks,


Tong Chen (Seattle USA)<br />SCJP,SCWCD,SCDJWS,IBM XML,MCP.NET,MCAD.NET,MCSD.NET
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671

Presizing the StringWriter is optional, but improves performance. Here I assumed that the file encoding was one byte per character. If that's not the case you may wish to presize differently - e.g. for UTF-16 use


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there an efficient way to read a text file into a string?
 
Similar Threads
Is there an efficient way to read a text file into a string?
Parse a text file and save to a database
Read a 5.6 mb text file
String Searching in huge Text file
Occurence of given string in a large text file