Results 1 to 3 of 3

Thread: Array Troubles

  1. #1
    shodai is offline Senior Member
    Join Date
    Apr 2012
    Posts
    106
    Rep Power
    0

    Default Array Troubles

    So I am trying to open a file and store the contents into a two dimensional array. I seem to have no problem using this same basic code to read the file and output it. But when I try to change it so that all the data is stored into the array, it does not work. Any suggestions?
    Java Code:
      public void convertFile()
      {
        String filePath = ("C:\\Users\\Brad\\Downloads\\FB1.csv");
        String [][] rowCol = new String [429][6];
        try
        {
          BufferedReader br = new BufferedReader(new FileReader(filePath));
          StringTokenizer st = null;
          System.out.println("Your file is being converted to an array. This may take several minutes.");
    
          while((filePath = br.readLine()) != null)
          {        
            st = new StringTokenizer(filePath, ",");
    
            for (int rowNumber = 0; rowNumber < rowCol.length; rowNumber++);
            {
              for (int columnNumber = 0; columnNumber < rowCol[rowNumber].length; columnNumber++);
              {
                System.out.println(rowCol[rowNumber][columnNumber]);
              }
            }
            columnNumber = 0;
          }
        }
        
        catch (FileNotFoundException e)
        {
          System.out.println ("File cannot be converted to an array");
        } 
        
        catch (IOException e) 
        {
          System.out.println ("File cannot be converted to an array");
        }
    
      }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,985
    Rep Power
    9

    Default Re: Array Troubles

    What do you mean when you say "it doesn't work"? What does it do instead?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,771
    Rep Power
    5

    Default Re: Array Troubles

    First, you haven't populated the array with anything. Second, you repeatedly print out the unpopulated array every time you read a line.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Troubles with a Change app
    By kiLzeD in forum New To Java
    Replies: 2
    Last Post: 09-28-2011, 11:29 PM
  2. synchronizing troubles
    By AedonetLIRA in forum Threads and Synchronization
    Replies: 1
    Last Post: 10-12-2010, 11:38 PM
  3. Integer troubles again...
    By Tb0h in forum New To Java
    Replies: 1
    Last Post: 09-20-2009, 02:32 AM
  4. [SOLVED] Array troubles, yes I searched...
    By Reiyn in forum New To Java
    Replies: 11
    Last Post: 04-16-2009, 11:28 PM

Posting Permissions

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