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

Sybex 816, Appendix B, page 688 errata

 
Greenhorn
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.
     
    Marshal
    Posts: 71630
    312
    • 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
    819
    Eclipse IDE VI Editor Java
     
    Fire me boy! Cool, soothing, shameless self promotion:
    the value of filler advertising in 2020
    https://coderanch.com/t/730886/filler-advertising
    reply
      Bookmark Topic Watch Topic
    • New Topic