1 / 5

Readers

Readers. a means of reading text. What are readers?. Inputs a stream Outputs a String Unicode is produced from ASCII input Manage the translation from non ASCII input ASCII – American Standard Code for Information Interchange EBCDIC – Extended Binary Coded Decimal Interchange Code.

mabyn
Download Presentation

Readers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Readers a means of reading text

  2. What are readers? • Inputs a stream • Outputs a String • Unicode is produced from ASCII input • Manage the translation from non ASCII input • ASCII – American Standard Code for Information Interchange • EBCDIC – Extended Binary Coded Decimal Interchange Code.

  3. How do I build a reader? BufferReader br = new BufferedReader(new InputStreamReader(new FileInputStream(f))); .... while ((String s = br.readLine()) != null) { processLine(s); }

  4. Simple encryption try { FileReader fr = new FileReader("input.txt"); int c = reader.read(); while(c != -1) { char newC = encrypt((char) c); System.out.print(newC); c = reader.read(); } reader.close(); }......add a catch clause......

  5. BufferedReader: one line at a time • Analogously, you may want to read in a line at a time • Use BufferedReader • public BufferedReader(Reader in) • public String readLine() • returns null on EOF

More Related