Results 1 to 2 of 2
  1. #1
    uhertz is offline Member
    Join Date
    Jun 2011
    Rep Power

    Default Reading lines into 2d array

    I need to read a textfile line by line into a two dimensional array.
    The array would be an array of strings. I'm thinking to use an arraylist of type string
    The string is always two words and the text file contains 15 lines of two word strings.
    How do I do this? Can I declare an arraylist of type String and then use the string split method ?
    IF so, how do I get the split string elements into the array?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Reading lines into 2d array

    Do you want the data in a 2 dim array or in an ArrayList?
    If an array, would each row hold two columns of the data from each file record?

    The split method would be useful to parse the line into an arrray of two Strings that could be assigned to each row of the 2 dim array.

Similar Threads

  1. Reading Lines
    By gkoef in forum New To Java
    Replies: 6
    Last Post: 04-19-2011, 11:08 PM
  2. reading lines from URL and printing backwards
    By luxurymode in forum Advanced Java
    Replies: 1
    Last Post: 03-30-2011, 08:18 AM
  3. Two '\n' characters between lines while reading File
    By subith86 in forum New To Java
    Replies: 6
    Last Post: 02-26-2011, 09:56 AM
  4. problem reading a files lines
    By j187 in forum New To Java
    Replies: 1
    Last Post: 12-17-2010, 12:43 AM
  5. Reading specific lines
    By ivvgangadhar in forum New To Java
    Replies: 8
    Last Post: 01-12-2009, 08:53 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