// Page 168 //import java.io.PrintWriter; import java.io.File; import java.util.Scanner; public class SortedListDemo { public static void main(String[] args) throws java.io.FileNotFoundException { Scanner inputStream = new Scanner(new File("data.txt")); //PrintWriter outputStream = new PrintWriter("out.txt"); Scanner input=new Scanner(System.in); SortedList myList = new SortedList(); int item; while(inputStream.hasNextInt()) { item = inputStream.nextInt(); myList.Insert (item); } inputStream.close(); //outputStream.close(); System.out.println("Total = " + myList.Length()); System.out.println("The list is: "); myList.Print (); // Search an item System.out.println("Type the item to be found: "); item = input.nextInt(); if (myList.IsPresent (item)) System.out.println("Found.\n"); else System.out.println("Not find.\n"); } }