/**
*
*
*
*
*/

import java.io.*;

final class CDDBFileOpener{

	private String line = "";
	private String xmcdContent = "";
	private File file;
	private FileReader fileOpener;
    private BufferedReader inFile; 
    
	public String getCDDBFile(String fileName){
		try {
			file = new File("Fred", fileName);
		    if (!file.exists()){
				System.out.println("The file does not exist. Trying other directory");
				file = new File("Zac", fileName);    
			}
    		//read input file from disk
    		fileOpener = new FileReader(file);
    		inFile = new BufferedReader(fileOpener);
   	  		line = inFile.readLine();
      		while (line != null) {
	    			xmcdContent += line;
        			line = inFile.readLine();
        			if (line != null){
	        			xmcdContent += "\n";	
	        		}
      		}
      		inFile.close(); 
		}
    	catch (FileNotFoundException e) {
      		System.out.println("File not found. Make sure input files exist.");
    	}
    	catch (IOException e) {
      		System.out.println("Incorrect data format.");
    	}
    	catch (Exception e) {
      		System.out.println(e.toString());
    	}
    	return xmcdContent;
	}
} //end class