Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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

Errata OCP study guide JSE 11 Programmer II, question 10 chapter 9.

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Using APPEND, if the target file already exists, the contents of source file will be append to the end of target file and if the target not exists will be thrown an exception.

Making letter C and E correct.

Img -> https://ibb.co/N7T7Y04
 
Marshal
Posts: 26289
80
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you simply asserting that an exception will be thrown, or do you have some evidence for that statement?

(By the way: when you make a post, isn't there an "Attachments" tab at the bottom of the box where you type your post? Using that would be much preferred compared to making readers go to some other site.)
 
Nicholas Barbosa
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Are you simply asserting that an exception will be thrown, or do you have some evidence for that statement?

(By the way: when you make a post, isn't there an "Attachments" tab at the bottom of the box where you type your post? Using that would be much preferred compared to making readers go to some other site.)



Yes!



If "target" not exists, an exception will be thrown. In case you haven't tested the photo code, here is a problem related to APPEND enum value in the stackoverflow.

Stackoverflow->https://stackoverflow.com/questions/30908816/java-nio-file-nosuchfileexception-why-nio-not-creating-file

Excerpt from the stackoverflow response that proves that the letter C is correct and not B, "You're using StandardOpenOption.APPEND, but that won't create a file; it will append to an existing file."
Screenshot-2020-12-30-170624.png
question 10,chapter 9.
question 10,chapter 9.
 
Paul Clapham
Marshal
Posts: 26289
80
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the answer you posted goes on to say "The APPEND option creates the file if it does not exist" but that appears to be false. The documentation for APPEND certainly doesn't say that and the Stack Overflow poster was complaining that APPEND didn't create the file too.
 
Marshal
Posts: 71682
312
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please search; I think somebody reported this problem a few weeks ago.
 
Sheriff
Posts: 22054
113
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The official documentation of Files.newBufferedWriter is oddly unclear about what to do in this case.

Fortunately, I've written a few file system implementations myself, and therefore know that implementing a file system does not require implementing any methods for creating a writer. The only writable objects you can create are:
* an OutputStream: Files.newOutputStream
* a SeekableByteChannel: Files.newByteChannel

The documentation for newOutputStream clearly states that APPEND without CREATE should cause an exception to be thrown if the file does not exist. Therefore, answer C is correct, and the answer explanation is incorrect.
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic