• 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

BufferedReader is not Serializable?

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

I am trying to guess why I can't run correctly my program. My code is this one:





When I choose the option number 3 I displayed the error:

Error al leer del fichero
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.io.BufferedReader

After reading the error I thought the BufferedReader class is not serializable, so I decided became it transient:



But when I run the program again I got the same error.

What's wrong?

Thanks.

 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
most of the stream classes in java.io. are not searializable, which make sense to not make them store because they are *live* stream.

how about Venta in your class?
 
Alex Garci
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Here is the code of Venta class:

 
Master Rancher
Posts: 4806
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your fix making the BufferedReader transient should fix the problem - if it doesn't, that probably means you still have traces of the old code lying around. Try deleting all your .class files, and the Ventas.dat file as well, which may contain data serialized from the old code.
 
Mike Simmons
Master Rancher
Posts: 4806
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alex Garci wrote:When I choose the option number 3 I displayed the error:

Error al leer del fichero
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.io.BufferedReader


That doesn't seem to match the code you showed - are you reading or writing? Also your code shows that you're printing the stack trace - what does that output look like?
 
Alex Garci
Greenhorn
Posts: 15
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have deleted all .class files and Ventas.dat file as you told me and now it works.

Thank you for the answer Mike.
reply
    Bookmark Topic Watch Topic
  • New Topic