if i have a text file with data:
test, 1, 2
again, 3, 4

Can someone give me an idea how to start puting each line into an object ?
ObjectName o = new ObjectName(String s1, String s2, String s3);

class Action implements ActionListener {
		     public void actionPerformed (ActionEvent e) {
		 
                   File file = new File("test.txt");
                   StringBuffer contents = new StringBuffer();
                   BufferedReader reader = null;

                   try
                   {
                      reader = new BufferedReader(new FileReader(file));
                      String text = null;

                     // repeat until all lines is read
                     while ((text = reader.readLine()) != null)
                     {
                       contents.append(text).append(System.getProperty("line.separator"));
                     }
                  
	          } catch (FileNotFoundException e)
                   {
                       e.printStackTrace();
                   } catch (IOException e)
                   {
                       e.printStackTrace();
                   } finally
                   {
                   try
                   {
                     if (reader != null)
                     {
                       reader.close();
                     }
                   } catch (IOException e)
                   {
                     e.printStackTrace();
                   }
                   }
        
        // show file contents here
       // System.out.println(contents.toString());
		
		 
    }
}

Why not splitting the String using String.split(",") method?

pseudocode:

define class for new objects
   3 variables
   constructor that takes 3 values to set the variables

...
actionperformed
  loop:
    read next line from file
    use split (as above) to separate the 3 fields
    create new object using the 3 fields 
    add new object to an ArrayList
  end loop
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.