File as a String object

Discussion in 'Java' started by zku, Jul 30, 2003.

  1. zku

    zku Guest

    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
     
    zku, Jul 30, 2003
    #1
    1. Advertisements

  2. On Wed, 30 Jul 2003 16:26:01 +0800, zku wrote:
    > 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

    --
    [ do not send me private copies of your followups ]
    g o r d o n . b e a t o n @ e r i c s s o n . c o m
     
    Gordon Beaton, Jul 30, 2003
    #2
    1. Advertisements

  3. zku

    Roedy Green Guest

    Roedy Green, Jul 30, 2003
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. darrel
    Replies:
    7
    Views:
    2,727
    darrel
    Mar 22, 2006
  2. Matt
    Replies:
    7
    Views:
    19,542
    Andrew Thompson
    May 19, 2004
  3. Replies:
    3
    Views:
    1,007
    Tony Morris
    Jan 25, 2005
  4. jon wayne
    Replies:
    9
    Views:
    1,001
    Jim Langston
    Sep 22, 2005
  5. Fei Liu
    Replies:
    9
    Views:
    694
  6. ankur
    Replies:
    1
    Views:
    14,430
    Jan =?UTF-8?B?VGhvbcOk?=
    Aug 27, 2007
  7. Rakesh
    Replies:
    10
    Views:
    12,695
    Mike Schilling
    Apr 8, 2008
  8. Pokkai Dokkai
    Replies:
    8
    Views:
    293
    Phrogz
    Nov 18, 2007
Loading...