import java.io.*; import java.util.Scanner; class Main { public static void main(String[] args) throws FileNotFoundException { Scanner sFile = new Scanner(new File("a.txt")); // this file contains "apple orange" Scanner sKeyboard = new Scanner(System.in); // keyboard Scanner sString = new Scanner("Lecture(3hrs) and lab(2hrs)"); // the string String s1, s2, s3; s1 = sFile.next(); s2 = sKeyboard.next(); s3 = sString.next(); System.out.println("all: " + s1 + " " + s2 + " " + s3); System.out.println("-----------"); while (sFile.hasNext()) { System.out.println(sFile.next()); } System.out.println("-----------"); while (sKeyboard.hasNext()) { // Need ^Z to stop!!!! System.out.println(sKeyboard.next()); } System.out.println("-----------"); while (sString.hasNext()) { System.out.println(sString.next()); } sFile.close(); sKeyboard.close(); sString.close(); } } /* mock test midterm exam all: apple mock Lecture(2hrs) ----------- orange ----------- test midterm exam ----------- and lab(2hrs) */