Skip to main content
O'Reilly home
    • Sign In
    • Try Now
    • Teams
    • Individuals
    • Features
      • Certifications
      • Interactive learning
      • Live online sessions
    • What’s New
    • O’Reilly for marketers

Java For Everyone: Compatible with Java 5, 6, and 7, 2nd Edition by

Get Java For Everyone: Compatible with Java 5, 6, and 7, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.

Start your free trial

CHAPTER 7

INPUT/OUTPUT AND EXCEPTION HANDLING image

CHAPTER GOALS

To read and write text files

To process command line arguments

To throw and catch exceptions

To implement programs that propagate checked exceptions

CHAPTER CONTENTS

7.1 READING AND WRITING TEXT FILES

Common Error 7.1: Backslashes in File names

Common Error 7.2: Constructing a scanner with a string

Special Topic 7.1: Reading Web Pages

Special Topic 7.2: File Dialog Boxes

Special Topic 7.3: Reading and Writing Binary Data

7.2 TEXT INPUT AND OUTPUT

Special Topic 7.4: Regular Expressions

Video Example 7.1: Computing a Document's Readability image

7.3 COMMAND LINE ARGUMENTS

How To 7.1: Processing Text Files

Random Fact 7.1: Encryption Algorithms

Worked Example 7.1: Analyzing Baby Names image

7.4 EXCEPTION HANDLING

Syntax 7.1: Throwing an Exception

Syntax 7.2: Catching Exceptions

Syntax 7.3: The throws Clause

Syntax 7.4: The finally Clause

Programming Tip 7.1: Throw Early, Catch Late

Programming Tip 7.2: Do Not Squelch Exceptions

Programming Tip 7.3: Do Not Use catch and finally in the Same try Statement

Special Topic 7.5: Automatic Resource Management in Java 7

Random Fact 7.2: The Ariane Rocket Incident

7.5 APPLICATION: HANDLING INPUT ERRORS ...

Get Java For Everyone: Compatible with Java 5, 6, and 7, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.

Start your free trial

About O’Reilly

  • Teach/write/train
  • Careers
  • Community partners
  • Affiliate program
  • Diversity

Support

  • Contact us
  • Newsletters
  • Privacy policy
facebook-logo linkedin-logo youtube-logo

Download the O’Reilly App

Apple app store Google play store

Take O’Reilly online learning with you and learn anywhere, anytime on your phone and tablet.

  • Get unlimited access to books, videos, and live training.
  • Sync all your devices and never lose your place.
  • Learn even when there’s no signal with offline access.

Do not sell my personal information

Exercise your consumer rights by contacting us at donotsell@oreilly.com.

O'Reilly home

© 2021, O’Reilly Media, Inc. All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.

Terms of service • Privacy policy • Editorial independence