package lab4A; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.PrintWriter; import java.util.Iterator; import java.util.Scanner; public class TestSet { /** * @param args */ public static void main(String[] args) throws FileNotFoundException,IncorrectFormatException{ Set set1= new BSTSet(); Scanner inputStream = null; /** Set up input and output files */ try { inputStream= new Scanner(new FileReader("unsorted1000.txt")); } catch(FileNotFoundException e) { System.out.println("input file was not found"); System.out.println("or could not be opened"); System.exit(0); } //PrintWriter outputStream=null; //try //{outputStream= // new PrintWriter(new FileOutputStream("Sorted1000.txt")); // //} // //catch(FileNotFoundException e) //{System.out.println("Error opening the results file"); //System.exit(0); //} while (inputStream.hasNext()){ try { if (!inputStream.hasNextInt()) throw new IncorrectFormatException(inputStream.next()); else set1.add(inputStream.nextInt()); } catch (IncorrectFormatException error){ System.out.println("incorrect format" + error); System.exit(0); } } System.out.println("The original set is:\n"+set1 + "\n\n\n"); System.out.println("set contains 115 is: " + set1.contains(115)); System.out.println("set contains 125 is: " + set1.contains(125)); } }