Results 1 to 2 of 2
  1. #1
    Skorge is offline Member
    Join Date
    Nov 2009
    Posts
    1
    Rep Power
    0

    Question Help with arrays

    Hello,
    I'm a bit confused on how to do this. I'm supposed to open a dictionary file and store all of its values into an array. My guide tells me that I need to:

    "read in the name of the dictionary file from command-line-arguments, then read in a dictionary of words from the data file, store each word in an array....."

    I'm not exactly sure how to read the dictionary file from the command line arguments. Any help? :confused:

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

    Default

    Quote Originally Posted by Skorge View Post
    Hello,
    I'm a bit confused on how to do this. I'm supposed to open a dictionary file and store all of its values into an array. My guide tells me that I need to:

    "read in the name of the dictionary file from command-line-arguments, then read in a dictionary of words from the data file, store each word in an array....."

    I'm not exactly sure how to read the dictionary file from the command line arguments. Any help? :confused:
    You don't. You read in the file name from the command line, then use that name to open a file for reading (myself I'd use a Scanner object for this. something like:

    Java Code:
    //pseudocode
    main method 
      if the length of the args array is > 0 give args[0] to String fileName 
      Create a File object using fiileName
      Use this File to create a Scanner object
      initialize a counter int to 0
      while scanner's nextLine exists
        dictionary array [counter] gets assigned scanner's nextLine
        increment counter 
      end while
    end main

Similar Threads

  1. Arrays
    By karabo101 in forum New To Java
    Replies: 12
    Last Post: 10-11-2009, 06:02 PM
  2. Arrays
    By swim_fan08 in forum New To Java
    Replies: 7
    Last Post: 04-11-2009, 04:02 PM
  3. Need help with Arrays
    By dietgal in forum New To Java
    Replies: 21
    Last Post: 10-08-2008, 02:59 PM
  4. need help with arrays
    By Jman in forum New To Java
    Replies: 17
    Last Post: 07-21-2008, 03:34 AM
  5. 2D-Arrays
    By kbyrne in forum New To Java
    Replies: 1
    Last Post: 02-07-2008, 11:08 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
  •