Results 1 to 3 of 3
  1. #1
    blkshp1990 is offline Member
    Join Date
    Nov 2009
    Rep Power

    Default Reading a txt file and then storing it in a 2d array

    This has got me completely stumped.

    Part of a project I'm doing requires me to write a method that loads in a txt file that contains "-"s and "0"s that form a grid image.

    An example of this is...


    Next i need to store this information into an ArrayList object two dimensional.
    And it should be a 2d array of chars.

    Any help would be highly appreciated.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    It's always best to first try to solve this on your own, and then failing that, post your best attempt here. Otherwise you'll be cheating yourself out of a valuable educational opportunity. Much luck!

  3. #3
    blkshp1990 is offline Member
    Join Date
    Nov 2009
    Rep Power

    Default I'm not trying to cheat

    I'm just asking for assistance with one specific method in my big program that I have to do that has me completely stumped.

    I've been trying for quite some time to solve this. All i know is that I have to use the BufferedReader and read in the txt file and then somehow put the data into a 2d array.

    I'm clueless on how to do that -.- I would put some code if i knew.

    maybe this code is used...???

    public void load(String sourceName) {

    BufferedReader br = new BufferedReader(new FileReader(sourceName));
    Followed by code to put data into a 2d array? idk -.- haha

Similar Threads

  1. [SOLVED] Reading a text file into an Array
    By DonCash in forum New To Java
    Replies: 13
    Last Post: 01-25-2011, 01:51 AM
  2. Reading text file into an array
    By Mahesh_ps in forum New To Java
    Replies: 1
    Last Post: 10-09-2009, 03:04 PM
  3. Reading from a file to make an array
    By Bomber_Will in forum New To Java
    Replies: 11
    Last Post: 01-21-2009, 09:19 AM
  4. Reading input file into an array
    By littlefire in forum New To Java
    Replies: 6
    Last Post: 10-18-2008, 11:51 PM
  5. Reading/Writing a File using byte array
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-16-2008, 11:41 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