HI, a pretty frustrating problem arose. I am not going to post any code this time. This should be straight forward question anyways... :)

I have a class that contains a constructor with arrays. Also, a methods to add to the array using scanner class.

The problem is, I implemented serialization in that class. When I instantiated that class inside the main method as an object, I tried to save it to a file via Serialization. But when the code to save the file is ran, it throws an exception like this:

java.io.NotSerializableException : java.util.scanner

How do I fix this problem?? I checked the Java API and it says that scanner is Serializable.

I pray that I don't need to delete the scanner objects.

As of JDK 1.6, Scanner does not implement the Serializable interface. Here is the declaration from the code:

public final class Scanner implements Iterator<String> {

Unfortunately, it being final means that you can't subclass it either. The only way to get around this problem, aside from writing your own Scanner class, is to declare your scanner member variable as transient, which means that the JVM won't try to serialize it when you write your object.

Thanks, tried that and it worked...However...Since I am writing an object that contains an array of objects to a file, when I opened the file back, it should work, right? And yes it did work, opening the object and displaying its array contents that I saved. Except that I cannot add any objects to that opened array anymore. It throws a nullpointer exception?? How to solve this...This is the final step I must overcome.

I want to take this moment to thank dononelson...

Another question...

Today, while browsing trusted websites, I see JavaSE Binary running automatically in my toolbar, then my anti-virus program Kaspersky 2010 acts up saying that it is a dangerous object and required me to quarantine it. So is JavaSE Binary automatically running a normal sign?? I am new to this sort of thing.

Edited 5 Years Ago by Limiter: n/a

Yes, it is normal. There's probably some java applet that spawned java to run. I'd be a little concerned about the anti-virus saying it was a dangerous object. Either your anti-virus is crazy, or something has replaced your jre with a java.exe that isn't authentic. I'd try another anti-virus program and see if it gives you the same results.

What about the fact that an opened, "deneralized" file cannot be mutated, as noted above. Is there a bypass?

Can you post your code? Perhaps I can help you debug it. Don't forget to use the (code) button.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.