• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Sybex 816, Chapter 8, pag. 443

Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Chapter 8, pag. 443, the constructors for FileReader and FileWriter are introduced. All the constructors are said to throw a FileNotFoundException, but the official Java 11 documentation says that the constructors for FileWriter throw an IOException.
Posts: 70666
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please go through the source for those constructors. You may find they contain lines like ...throw new FileNotFoundException(...);. Since FileNotFoundException is a strict subtype of IOException, you may find that both the following statements are true.
  • 1: Those constructors declare an IOException
  • 2: If anything goes wrong creating an instance, a FileNotFoundException will be thrown.
  • The declaration (No 1) determines the handling of code by the compiler and the throw statement determines the runtime type of any exception actually thrown. I am not sure about this, but the source may elucidate the problem further.
      Bookmark Topic Watch Topic
    • New Topic