Results 1 to 2 of 2
  1. #1
    HardRock is offline Member
    Join Date
    Jun 2012
    Posts
    5
    Rep Power
    0

    Default How to take contents of file in a string?

    How to get contents of file in a string please help.

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    757
    Rep Power
    8

    Default Re: How to take contents of file in a string?

    If your text file is small in size, the fastest way will be using the java.nio.file.Files.readAllLines() method. This method take a Path as a parameter. This method will then give the result as a collection, a List of String objects. You'll need to use Java 7 for this.

    For detail you can find it here: Files (Java Platform SE 7 )

Similar Threads

  1. Replies: 2
    Last Post: 03-18-2012, 04:09 AM
  2. Replies: 5
    Last Post: 11-17-2011, 04:45 PM
  3. Checking The Contents of a String
    By jayragz in forum New To Java
    Replies: 7
    Last Post: 05-26-2011, 10:15 AM
  4. Comparing contents of a file with String[]
    By eponcedeleon in forum Advanced Java
    Replies: 2
    Last Post: 02-25-2010, 09:10 PM
  5. Concatinating contents of a string array based on condition
    By gangsterooseven in forum Advanced Java
    Replies: 2
    Last Post: 10-07-2009, 07:35 AM

Tags for this Thread

Posting Permissions

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