Scanner
usage
1 2 3 4 5 6 7 8 9 |
import java.io.*; // for File import java.util.*; // for Scanner public class FileScannerDemo { public static void main(String[] args) throws FileNotFoundException { File f = new File("test.txt"); Scanner input = new Scanner(f); } } |
File
class is in the java.io
packageScanner
object on that file's File
objectScanner
object on a File
needs to acknowledge the possibility of a FileNotFoundException
throws
clause is like a legal waiver: "I know bad things will happen if the file is missing but I accept that"