import java.io.*;
import java.util.Scanner;

/*********************************************************************
*
* @author Duncan Buell
*/
public class Sub3
{

  public Sub3()
  {
  } // public Sub3()

//
// This is the version of doSub3 that takes only one input file as
// a parameter.
//
// In this program we are going to read in all the data as string
// data.  This makes irrelevant all the error issues about expecting
// an int and getting a double, for example.
//
// Please note one of the main subtle messages of this code segment.
// The penalty for the equivalent of a fencepost error in reading data
// is either that you don't read the last line or last entry (that is,
// that you go one iteration of the read too few), or else that you try
// to read data after having read all the data, and thus read one too
// many times and cause a run-time error.
//
// This loop avoids those errors by testing at the top of the loop in the
// 'while' whether data of any sort exists (you can always read strings)
// and continuing into the loop only if data exists.
//
  public void doSub3(Scanner dataFile)
  {
    String inString = null;

    while(true == dataFile.hasNext())
    {
      inString = dataFile.next();
      System.out.println("string is " + inString);
    }
  } // public void doSub3(Scanner dataFile)

//
// This is the version of doSub3 that takes both an input file and
// and output data file as parameters.
//
// All else is the same as for the other version of the method. 
//
  public void doSub3(Scanner inputDataFile,PrintWriter outputDataFile)
  {
    String inString = null;

    while(true == inputDataFile.hasNext())
    {
      inString = inputDataFile.next();
      outputDataFile.println("file version string is " + inString);
    }
  } // public void doSub3(Scanner inputDataFile)

} // public class Sub3

