Results 1 to 5 of 5

Thread: Reading a File

  1. #1
    zoom1017 is offline Member
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

    Default Reading a File

    I'm fairly new to Java and I'm trying to read data from a file, and then implement the Quicksort algorithm to sort the resulting the array. The file is entered by the user, but it must adhere to the following format:

    3
    -2
    6
    8
    (where the first line indicates the number of numbers that are to follow).
    I have searched the forum thoroughly and although there is a plethora of threads addressing reading a file line by line, I don't know what modifications to make when I am prompting the user for a file as opposed to just entering one. I am not worried about Quicksort as much as I am reading the file and then converting the strings to integers. If someone can help, I'd be more than appreciative.

  2. #2
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    what about this one ?
    BufferedReader read=new BufferedReader(new FileReader("file.txt"));

  3. #3
    zoom1017 is offline Member
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

    Default

    Now I look smart.

  4. #4
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    what you mean saying that? Is the topic solved or what?

  5. #5
    MK12's Avatar
    MK12 is offline Senior Member
    Join Date
    Jan 2009
    Posts
    185
    Rep Power
    6

    Default

    As far as I can tell it sounds like he's sarcastically saying he looks smart, because he didn't think of that.
    (please mark as solved by going to the top of the page->Thread Tools->Mark This Thread As Solved)
    -MK12
    Tell me if you want a cool Java logo avatar like mine and I'll make you one.

Similar Threads

  1. Reading from csv file.plz help!!!!!!!!!!
    By sanjayksaini in forum New To Java
    Replies: 1
    Last Post: 12-19-2008, 07:41 AM
  2. help in reading file.
    By wanw84 in forum New To Java
    Replies: 2
    Last Post: 10-21-2008, 03:17 PM
  3. Help reading file
    By fritz1474 in forum New To Java
    Replies: 4
    Last Post: 09-17-2008, 03:28 AM
  4. Right use of file reading ?
    By jurka in forum New To Java
    Replies: 3
    Last Post: 08-27-2008, 08:16 PM
  5. Reading a file for use
    By peachyco in forum New To Java
    Replies: 2
    Last Post: 11-27-2007, 03:49 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
  •