Results 1 to 2 of 2
  1. #1
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Rep Power

    Default how to store the instances of this file

    I have a file with a list of mixed instances and I need to collect all instances in some java structure (I was wondering if I should use a List of lists for this):

    File structure
    ID, other content...
    1, ...
    3, ...
    1, ...
    2, ...
    2, ...
    3, ...

    I need to store all rows starting with 1 in a List1, rows with 2 in List2 and so on..

    all those lists should be in one single list so I can iterate among them.

    I don't know in advance the amount of ids...
    Is is a good approach ?


  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power


    Use a Map for that where the key values are the IDs and the value values are Lists of the lines from you file. a Map<Integer, List<String>> will do.

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Store Text-file Into 2D Array
    By benn22 in forum New To Java
    Replies: 20
    Last Post: 03-09-2011, 09:17 PM
  2. How do I store images in a zip file in Java
    By mglover in forum Advanced Java
    Replies: 1
    Last Post: 06-11-2010, 03:53 PM
  3. store data into an array from a file
    By chopo1980 in forum New To Java
    Replies: 10
    Last Post: 11-13-2009, 09:48 AM
  4. How to store property file into key value pair
    By Java Tip in forum java.util
    Replies: 0
    Last Post: 04-05-2008, 10:16 AM
  5. store file
    By kazitula in forum Java Applets
    Replies: 0
    Last Post: 02-17-2008, 09:45 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