Results 1 to 4 of 4

Thread: Read a TXT file

  1. #1
    JSN1 is offline Member
    Join Date
    May 2012
    Posts
    6
    Rep Power
    0

    Exclamation Read a TXT file

    Hi everyone.

    As posted before, I'm new to java and would like to ask for some help with this.

    Background

    My class will read this list:

    ("something", "something2", x.....

    I want to read those strings from a txt file, this strings come like this

    something
    something2

    and so...

    Could you please help me to solve this?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Read a TXT file

    Have a look at the Java tutorials on Basic I/O where it should explain all this and more: Lesson: Basic I/O.

    Please come on back if anything confuses you.

  3. #3
    JSN1 is offline Member
    Join Date
    May 2012
    Posts
    6
    Rep Power
    0

    Default Re: Read a TXT file

    Quote Originally Posted by Fubarable View Post
    Have a look at the Java tutorials on Basic I/O where it should explain all this and more: Lesson: Basic I/O.

    Please come on back if anything confuses you.
    Thanks!!!!!! I'm able to read the file,

    Java Code:
     System.out.println(contents.toString());
    Now, how can I write the lines into a single string?

    ("XYZ","EWW",.... etc

    Thanks

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: Read a TXT file

    What kind of variable(s) are the lines in?
    If in an array, you make a loop to concatenate all the lines into one String?
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 1
    Last Post: 08-05-2011, 09:21 PM
  2. Replies: 2
    Last Post: 05-11-2009, 10:07 AM
  3. Replies: 0
    Last Post: 02-11-2009, 09:53 AM
  4. Replies: 5
    Last Post: 02-05-2009, 10:28 AM
  5. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •