Results 1 to 6 of 6

Thread: Portable serialization

  1. #1
    Join Date
    Dec 2009
    Posts
    202

    Portable serialization

    Hello,
    I have an application where I serialize an object to store file. The serialization and de-serialization is going very well on my Windows machine. However, my colleague can serialize without exception and that it create a good file, cons impossible to deserialize, displaying the message "invalid / corrupt. And if I give him a file where I serialized an object, it can not read, that it displays the same thing.
    Last edited by ISAIAH; 28-01-2010 at 10:17 AM.

  2. #2
    Join Date
    Nov 2009
    Posts
    359

    Re: Portable serialization

    Hello,
    Even I have a similar kind of a problem, here is my code.
    Code:
    try {
    	ObjectInputStream input = new ObjectInputStream(new FileInputStream(file));
    Guilt gl = (Guilt) input.readObject();
    DrawinputgPanel fp = new DrawinputgPanel(gl, this);
    	this.jTabbedPaneMainput.add(fp.getGuiLTS().getName(), Fap);
    input.close();
    } catch (Exception ex) {
    	JOptionPane.showMessageDialog(this,
    			"File is corrupt / inputvalid.",
    			"Error",
    JOptionPane.ERROR_MESSAGE);
    }
    Any help on this will be highly appreciated.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Portable serialization

    Hi,
    I think something is missing in the try and the catch blocks. Not sure though but if you modify your ode, it would be great.
    Code:
    } catch (Exception ex) {
    	JOptionPane.showMessageDialog(this,
    			"File is corrupt / invalid.",
    			"Error",
    JOptionPane.ERROR_MESSAGE);
    }
    Kindly handle the exception in your code properly, so that they can be catch the exact exception.

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Portable serialization

    Hello,
    I agree with the above, I think it would be better if you add the printtrace in your code. Here is the code.
    Code:
    } catch (Exception ex) {
            ex.printStackTrace();
    JOptionPane.showMessageDialog(this,
    			"File is corrupt / invalid.",
    			"Error",
    JOptionPane.ERROR_MESSAGE);}
    By adding a printStackTrace () you'll have more details on the problem. Hope this will help you.

  5. #5
    Join Date
    Dec 2009
    Posts
    202

    Re: Portable serialization

    Hello,
    Indeed, in addition to message users, I added a printStackTrace. I asked another colleague to test on his machine (linux) and it works very well. It even happens to read files between our 2 platforms (Windows and Linux), makes the problem only occurs on Mac. Any ideas about this behavior. If you know about any other method, then please do post back with the same.

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Portable serialization

    Hello,
    It works on other machines? Without error? good because the error is quite explicit. Here it is
    java.io.NotSerializableExceptionJava.awt.geom.Rectangle2D$ Float
    You seem to try to serialize an object type Rectangle2D.Float while it does not implement Serializable, it seems rather difficult. I think it is better if you add some other method or other logic in your code.

Similar Threads

  1. Serialization in Vb.net
    By samualres in forum Software Development
    Replies: 5
    Last Post: 03-03-2010, 11:23 AM
  2. Advantages of serialization
    By ScarFace 01 in forum Software Development
    Replies: 5
    Last Post: 06-02-2010, 11:51 AM
  3. C sharp Serialization
    By Truster in forum Software Development
    Replies: 5
    Last Post: 14-01-2010, 08:40 AM
  4. What does serialization mean in java?
    By Honorata in forum Software Development
    Replies: 3
    Last Post: 24-11-2009, 08:35 AM
  5. Some questions regarding serialization
    By MABON in forum Software Development
    Replies: 3
    Last Post: 13-11-2009, 04:58 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,049,488.09173 seconds with 17 queries