Input, Tokens and Text File Handling - ISC Class 11 Computer Science Notes, Diagrams and Solved Questions

Reading input with Scanner, input and output exceptions, tokens, whitespace and delimiters, the StringTokenizer class, data files and streams, and creating, writing, reading, appending to and searching text files with FileWriter and FileReader.

In this chapter

  • Reading ints, decimals, words and lines with the Scanner class, and avoiding the nextLine() trap
  • Catching InputMismatchException and handling the checked IOException
  • What tokens, whitespace and delimiters are, and how to change the delimiter
  • Splitting strings with StringTokenizer: hasMoreTokens, nextToken and countTokens
  • Why data files are needed and how input, output and character streams work
  • Creating, writing and reading text files with FileWriter, FileReader and BufferedReader
  • Appending to a file and searching it record by record