Win a copy of Microservices Testing (Live Project) this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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

 
Ranch Foreman
Posts: 25
1
  • 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: 41184
848
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
Ranch Foreman
Posts: 25
1
  • 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
Ranch Foreman
Posts: 25
1
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic