• 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
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
  • salvin francis
  • Frits Walraven
  • Piet Souris

Sybex 816, Appendix B, page 688 errata

Posts: 10
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In answer to question 22 (Chapter 9: NIO.2) there is:

The APPEND option creates the file if it does not exist...

It refers to this code:

If the file does not exist, function newBufferedWriter will create it if:
  • no option at all is present (in this case method works as if the CREATE, TRUNCATE_EXISTING, and WRITE options are present; link to java docs)
  • option for creating is present (CREATE/CREATE_NEW)

  • Since StandardOpenOption.APPEND is already present, option for creating file must by written explicitly. Otherwise NoSuchFileException is thrown when file does not exist.
    Therefore option B is not correct and option C is correct.
    Posts: 71630
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Didn't find that in the errata. You are correct; I also tried such code on JShell and failed to create the file.
    author & internet detective
    Posts: 40354
    Eclipse IDE VI Editor Java
    Fire me boy! Cool, soothing, shameless self promotion:
    the value of filler advertising in 2020
      Bookmark Topic Watch Topic
    • New Topic