|
-
Mar 13th, 2007, 01:47 AM
#1
Thread Starter
Fanatic Member
Reading a file as a whole string.
I can't seem to find it on the net. Is there a way to just say
String s = someReader.ReadToEnd();
like the on in C#, all I have seen so far is the reading per line. Help anyone? Thanks!
Last edited by nebulom; Mar 13th, 2007 at 06:36 PM.
-
Mar 13th, 2007, 10:45 AM
#2
Addicted Member
Re: Reading a file as a whole string.
i dont know about a function to for reading all of it as a string but you can keep adding the new lines to the same string.
-
Mar 13th, 2007, 12:58 PM
#3
Frenzied Member
Re: Reading a file as a whole string.
You can make your own method with a StringBuffer, I guess. But there's nothing in the API to do what you want.
-
Mar 13th, 2007, 03:56 PM
#4
Re: Reading a file as a whole string.
But there is in the Springframework utilities or the Apache Jakarta Commons IO.
Springframework is too big to use unless you use its main facilities, but Commons IO is nice and small and a good addition.
http://jakarta.apache.org/commons/io...ase/index.html
Code:
String data = IOUtils.toString(new FileInputStream(filename), "UTF-8");
Hey, SysError, are you making fun of penagate?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Mar 13th, 2007, 04:03 PM
#5
Frenzied Member
Re: Reading a file as a whole string.
 Originally Posted by CornedBee
Hey, SysError, are you making fun of penagate?
I wasn't, but after the many personal attacks a few weeks ago, I like to think so now.
-
Mar 13th, 2007, 06:36 PM
#6
Thread Starter
Fanatic Member
Re: Reading a file as a whole string.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|