// File: ClientPhotoGallery.java
// Time-stamp: "2005-01-20 12:39:27 calvanese"
// Purpose: PhotoGallery: solution part 2

import java.io.*;

public class ClientPhotoGallery {

  public static void readFromFile(String filename, PhotoGallery g)
                                                      throws IOException {
    FileReader f = new FileReader(filename);
    BufferedReader br = new BufferedReader(f);
    String s = br.readLine();
    while (s != null) {
      g.add(s);
      s = br.readLine();
    }
    f.close(); // or equivalently br.close();
  }


  // method not requested by the specification
  public static void writeOnFile(String filename, PhotoGallery g)
                                                      throws IOException {
    FileWriter f = new FileWriter(filename);
    PrintWriter out = new PrintWriter(f);
    String[] photoarray = g.returnAllPhotos();
    for (int i = 0; i < photoarray.length; i++)
      out.println(photoarray[i]);
    f.close();  //or out.close();
  }

}
