> I, I'm trying to load an object serialized to a file using an
> ObjectOutputStream.
[quoted text clipped - 8 lines]
> Debugging I discovered that FileInputStream::available() return 258 bytes,
> while FileInputStream::available() returns 0.
[snip exception]
> This code is called from the method contextInitialized of a class
> implementing ServletContextListener.
[quoted text clipped - 5 lines]
> Thanks in advance
> Flavio
It could be that you aren't opening the file you think you are. Try
printing or logging "new File(pwdFileName).getCanonicalPath()", that
should tell you exactly which file you are opening. Generally you're
better off putting resources like this in your classpath, and using
ClassLoader.getResource(pwdFileName); the getResource method will
search all of your classpath and return the URL of the file.
Flavio Castelli - 26 Jul 2007 13:27 GMT
> It could be that you aren't opening the file you think you are. Try
> printing or logging "new File(pwdFileName).getCanonicalPath()", that
> should tell you exactly which file you are opening.
I've checked it using your suggestion and I'm opening the right file. It's
really strange, isn't it?
> Generally you're
> better off putting resources like this in your classpath, and using
> ClassLoader.getResource(pwdFileName); the getResource method will
> search all of your classpath and return the URL of the file.
I'll look also after it.
Any other suggestion?
Thanks
Flavio
PS: forgive me for the triple post in the ng, I had some problems with my
news server and google...
>3. SecretKey deskey = (SecretKey) keyFile.readObject();
>4. keyFile.close();
>
>I get a StreamCorruptedException at line 3.
The problem is where you WROTE the file. Your read does not match
your write, or classes changed in the interim.
Try creating the tiniest program that demonstrates your problem then
post the ENTIRE program.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com