vict0rjr 0 Newbie Poster
import java.io.*;

public class AlbumFile extends Album {
  public static void main(String[] args) {
    String fileName = FileChooser.pickAFile();
    String line = null;

// This array holds the album's pictures
    Picture picArray[] = new Picture[4];

// This array holds the album pictures' captions (descriptions)
    String captionArray[] = new String[4];

// Create the album
    AlbumFile myTrip = new AlbumFile();

// try to do the following
    try {
// create the buffered reader
      BufferedReader reader =
        new BufferedReader(new FileReader(fileName));

// Loop while there is more data
      while((line = reader.readLine()) != null) {

How can i modify this to make it work so that it reads from a text file and use it as an input to set an album name and display the pictures with the correct captions.

// print the current line
// *****you'll need to do more work here*****
    if (line != null ) {
    setAlbumName(line);
    } else {
        String []lineInfo = line.split(",");
    lineInfo[0] = lineInfo.trim();
    lineInfo[1] = lineInfo.trim();
Picture pic = new Picture(lineInfo[0]);
    }

       System.out.println(line);
    }



// close the reader
      reader.close();
    } catch(FileNotFoundException ex) {
      SimpleOutput.showError("Couldn't find " + fileName);
    } catch(Exception ex) {
      SimpleOutput.showError("Error reading file " + fileName);
      ex.printStackTrace();
    }

// Name the album
    myTrip.setAlbumName("My last trip.");

// Load the pictures
    myTrip.setPictures(picArray);

// Load the captions
    myTrip.setCaptions(captionArray);

// Show the album
    myTrip.showAlbum();

  } // main
} // class