• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OCP 17 Study Guide Chapter 14 I/O - Various Questions

 
Greenhorn
Posts: 25
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody! Almost finished with the Study Guide, and Chapter 14 was definitely the toughest one!

I have just two questions.

1)Why do that code throws an EOFException?

And this one not?

Is that the only way of obtaining an ObjcetOutput/InputStream? Aren't there any shortcut methods like Files.newBufferedReader(Path p)?

2) Are Collections Serializalbe?
List, Set and Map do not extend Serializable, but all of those implemetation do implement it (or most of them?). But all of the objects contained in those collection MUST implement Serializable. Is that correct? Is that on the exam?

I also think I've found two small errata in the textbook.

First one is on table 14.4, third line. The method "toAbsolutePath()" is not part of the Files class, and should be listed on table 14.3 as an instance method of class "Path".
The second is on the second code snippet above table 14.4:

Path method getName() needs an int parameter. I think it was instead intended the method getPathName().
 
author & internet detective
Posts: 41855
904
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marco Olivi wrote:1)Why do that code throws an EOFException?

And this one not?



I don't know. Interesting find.

Marco Olivi wrote:Is that the only way of obtaining an ObjcetOutput/InputStream? Aren't there any shortcut methods like Files.newBufferedReader(Path p)?


You could write your own helper method . But no, it isn't on Files. Probably because it is less common

Marco Olivi wrote:
2) Are Collections Serializalbe?
List, Set and Map do not extend Serializable, but all of those implemetation do implement it (or most of them?). But all of the objects contained in those collection MUST implement Serializable. Is that correct? Is that on the exam?


It's not on the exam. But you are correct. It is only serializable if the contents are.

Marco Olivi wrote:I also think I've found two small errata in the textbook.

First one is on table 14.4, third line. The method "toAbsolutePath()" is not part of the Files class, and should be listed on table 14.3 as an instance method of class "Path".


I just logged this on the errata from another thread.

Marco Olivi wrote:
The second is on the second code snippet above table 14.4:

Path method getName() needs an int parameter. I think it was instead intended the method getPathName().


It should have been getFileName(). Added to the errata
 
Marco Olivi
Greenhorn
Posts: 25
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Jeanne, you're always so kind!

I just logged this on the errata from another thread.



My post was a few hours earlier  
 
Marco Olivi
Greenhorn
Posts: 25
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:

Marco Olivi wrote:1)Why do that code throws an EOFException?

And this one not?



I don't know. Interesting find.



It looks like you can't create an ObjectInputStream from a file if it's output stream is still open, as well as you can't create it from a file that doesn't exist or is not an Object data file.
 
Greenhorn
Posts: 12
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I just logged this on the errata from another thread.



The errata item says:
795 14 On the second line, getName() should be getFileName() Marco Olivi 7/26/22

But the second line on page 795 is about a File, so getName() is ok.
I think, line 38 on page 796 is meant. Here we have a Path.
 
Jeanne Boyarsky
author & internet detective
Posts: 41855
904
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
Yes also now I have a duplicate errata. So going with the one I did right
 
I have a knack for fixing things like this ... um ... sorry ... here is a consilitory tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic