File as a String object

Z

zku

Hi,

I am trying to make a String object from a text file.

String text = ... the file's content.

as the file has " and \n and \ characters.

the String object is not proper created.

Any idea how?

tia
 
G

Gordon Beaton

I am trying to make a String object from a text file.

String text = ... the file's content.

as the file has " and \n and \ characters.

the String object is not proper created.

What exactly did you try? What kind of errors were there in the String
contents?
Any idea how?

Open the file with a FileInputStream and an InputStreamReader. Read
the file into e.g. a StringBuffer. After you reach the end of the
file, create a String from the StringBuffer.

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top