Scanner
objectScanner stdin = new Scanner(System.in);
System.in
= an InputStream
object predefined in java.lang
String inputLine = stdin.nextLine();
char c = inputLine.charAt(0); int i = Integer.parseInt(inputLine); long l = Long.parseLong(inputLine); float f = Float.parseFloat(inputLine); double d = Double.parseDouble(inputLine);
System.out
System.out
= a PrintStream
object predefined in java.lang
print println
String
s, and any object
(override the
toString
method to obtain desired format)
Scanner
objectFile srcFile = new File("myFile.txt"); Scanner fileIn = new Scanner(srcFile);
FileNotFoundException
(a checked exception)hasNext, hasNextInt, etc. next, nextInt, nextLine, etc. close
PrintStream
objectFile dstFile = new File("myFile.txt"); PrintStream outFile = new PrintStream(dstFile);
new PrintStream(File file) new PrintStream(String fileName)
print println close
String
s, and any object
(override the
toString
method to obtain desired format)