Results 1 to 2 of 2

Thread: Java IO Problem

  1. #1
    konayuki1510 is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default Java IO Problem

    Excuse me,
    I have a problem about the text file to store into array.

    I have a text file. It store three columns, Artist, Album and Tracks.

    I need to store these data data into array and perform the sorting..

    like this
    Java Code:
    Artist        Album             Tracks
    Peter    Peter Album           13
    John     John Album            14
    Mary     Mary Album           13
    How can I store the text file into array?
    And then, How can perform the sorting after store into array?
    Last edited by Fubarable; 03-06-2011 at 04:28 PM.

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Create an object with those three things as fileds, read the file line for line with a BufferedReader and populate these objects adding them to a list. Make sure the class implements Comparable and has a compareTo method, then sort the list using the Collections class and call toArray on the list (or call toArray on the List and sort the array using the Arrays class)..

Similar Threads

  1. Need Help!:( Java problem
    By ra21 in forum New To Java
    Replies: 2
    Last Post: 02-01-2011, 11:41 PM
  2. Problem Display Jmenubar Java Se6 u23 versus Java SE6 u22
    By Ravanelly in forum Advanced Java
    Replies: 0
    Last Post: 01-07-2011, 10:36 AM
  3. Problem with Java...
    By mc6415 in forum New To Java
    Replies: 10
    Last Post: 02-22-2010, 01:24 AM
  4. java problem
    By Mj Shine in forum New To Java
    Replies: 5
    Last Post: 08-15-2009, 06:09 AM
  5. Help, java problem
    By Suriman in forum New To Java
    Replies: 4
    Last Post: 03-09-2009, 05:26 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
  •