import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

/*********************************************************************
* DAB class of static constants and basic file checking routines.
* This is the header file of constants and methods that might be
* used in any and all contexts.
*
* @author Duncan Buell
*/
public class DAB
{
  public static final String DUMMYSTRING = "DUMMYSTRING";

/*********************************************************************
* PrintWriterOpen method to open a file as a PrintWriter.
* 
* The main purpose of this method is to do the error checking in
* a subordinate method so as not to clutter up the code flow
* in methods that have to open files.
* 
* @param  outFileName the (String) name of the file to open
* @return The opened PrintWriter known to be not null
*/
  public static PrintWriter PrintWriterOpen(String outFileName)
  {
    PrintWriter localPrintWriter = null;

    try
    {
      localPrintWriter = new PrintWriter(new File(outFileName));
    }
    catch (FileNotFoundException ex)
    {
      System.out.println("ERROR opening outFile " + outFileName);
      System.out.println(ex.getMessage());
      System.out.println("in" + System.getProperty("user.dir"));
      System.exit(1);
    }

    return localPrintWriter;
  } // public static PrintWriter PrintWriterOpen(String outFileName)

/*********************************************************************
* ScannerOpen method to open a file as a Scanner.
* 
* The main purpose of this method is to do the error checking in
* a subordinate method so as not to clutter up the code flow
* in methods that have to open files.
* 
* @param  inFileName the (String) name of the file to open
* @return The opened Scanner known to be not null
*/
  public static Scanner ScannerOpen(String inFileName)
  {
    Scanner localScanner = null;

    try
    {
      localScanner = new Scanner(new File(inFileName));
    }
    catch (FileNotFoundException ex)
    {
      System.out.println("ERROR opening inFile " + inFileName);
      System.out.println(ex.getMessage());
      System.out.println("in" + System.getProperty("user.dir"));
      System.exit(1);
    }

    return localScanner;
  } // public static Scanner ScannerOpen(String inFileName)

} // public class DAB

