title: combine some elements from 2 txt files into a third file
body: <p>I have two files Persons.txt and Hobby.txt.In the third file i want to put all the persons names and add each name some hobbies.This is how my files look like
  Persons.txt</p>
  
  <pre><code>ID;NUME;PRENUME;DATA_NASTERII;PROFESIA
  1;Stan;Ilie;22-01-1977;profesor;
  2;Becali;GG;01-07-1965;patron;
  3;Tanase;Cristian;07-12-1988;fotbalist;
  4;Pop;Ion;21-03-1984;pictor;
  5;Popescu;Rodica;17-04-1986;sculptor;
  </code></pre>
  
  <p>Hobby.txt</p>
  
  <pre><code>ID;NUME;DESCRIERE;NUMAR_MINIM_PERSOANE;ELEMENT_NECESAR
  1;baschet;sport in care se arunca mingea la cos;6;minge
  2;fotbal;sport in care nue voie sa atingi mingea in poarta adversa;14;minge
  3;chitara;cantatul la chitara;1;chitara
  4;pianul; cantatul la pian;1;pian
  5;programarea;scrierea de programe software;1;PC
  </code></pre>
  
  <p>I need a third file that looks like this:</p>
  
  <pre><code>Ion Pop : baschet, volei
  Ilie Stan: steaua, handbal
  </code></pre>
  
  <p>The problem is that i don't know </p>
  
  <ul>
  <li>how to get the persons name and </li>
  <li>how to append to them 2 or three hobbies.</li>
  <li>how to split each line from the file and write to the third file</li>
  </ul>
  
  <p>My code</p>
  
  <pre><code>   import java.io.*;
     import java.util.*;
     import java.util.ArrayList;
  
     public class ListaHobby {
               String line="";
               Persoana p = new Persoana();
               Hobby h = new Hobby();
               public void writeListaHobbies(){
                 try{
                       FileReader file1 =new FileReader("Persoane.txt");
                       Scanner scan = new Scanner(new File("Persoane.txt"));
                       ArrayList&lt;String&gt; values = new ArrayList&lt;String&gt;();
                       System.out.println(values.size());
  
                       FileReader file2 = new FileReader("Hobby.txt");
                       scan = new Scanner(new File("Hobby.txt"));
                       values = new ArrayList&lt;String&gt;();
                       System.out.println(values.size());
  
                       while(scan.hasNext()){
                                 values.add(scan.next());
                       }
  
                        BufferedReader br1 = new BufferedReader(file1);
                        BufferedReader br2 = new BufferedReader(file2);
  
                        String temp1="";
                        String temp2="";
  
                        while(br1.readLine() != null){
                          temp1 = br1.readLine() + temp1;
                        }
                        while(br2.readLine() != null){
                              temp2 = br2.readLine() + temp2;
                        }
  
                        String temp = temp1 + temp2;
  
                         FileWriter fw = new FileWriter("PersHobby.txt");
                         char buffer[] = new char[temp.length()];
                         temp.getChars(0, temp.length(), buffer, 0);
                         fw.write(buffer);
                         file1.close();
                         file2.close();
                         fw.close();
                      }
                      catch(IOException ex){
                             System.out.println("Error opening file.");
                             System.exit(1);
                      }`
  </code></pre>