This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Developer Career Masterplan: Build your path to senior level and beyond with practical insights from industry experts and have Heather VanCura and Bruno Souza on-line!
See this thread for details.
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

Sybex 816, Appendix B, page 688 errata

 
Greenhorn
Posts: 10
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 78406
    374
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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: 41762
    885
    Eclipse IDE VI Editor Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Agreed. Added to errata
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic