Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5954431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:58:12+00:00 2026-05-22T17:58:12+00:00

I use serialization to save data in my android app. Everything works beautifully until

  • 0

I use serialization to save data in my android app. Everything works beautifully until a user report he can not open his file.
After examined the file he sent to me, it turned out the problem is an EOFException when readObject().

I opened the .ser file in vim, it is not empty. It looks as normal as other files which can be opened normally.
No surprise happened when the user saved the .ser file.

My questions are:
1. Is it a wrong decision to use serialization in the first place?
2. My code works normally in most of the cases, but I may have missed something which eventually cause this problem.
3. The user said the file is INCREDIBLY important for him, so I really want to find a work around to open this file.

Here is the code how the file is readed:

    FileInputStream f_in = null;
    ObjectInputStream obj_in = null;

    f_in = new FileInputStream(fileName);
    obj_in = new ObjectInputStream (f_in);
    mBlock = (Block)obj_in.readObject();

Here is the code I use for saving a serializable.

saveObjToFile(mBlock, mFileName);

static void saveObjToFile(Serializable object, String fileName)                     
throws IOException{
    FileOutputStream f_out = null;
    ObjectOutputStream obj_out  = null;
    try{
        File note_file = new File(fileName);
        f_out = new FileOutputStream(note_file);
        obj_out = new ObjectOutputStream (f_out);
        obj_out.writeObject(object);
        obj_out.flush();
        obj_out.close();
    }finally{
        if (obj_out != null)
            try{
                obj_out.close();
            }catch(IOException e){

            }
        if (f_out != null)
            try{
                f_out.close();
            }catch(IOException e){

            }
    }
}

Here is a code snippet of Block definition:

public class Block implements Serializable{
        private static final long serialVersionUID = -4369689728261781215L;
        private int mType;
        private byte[] mContent;
        private ArrayList<Block> mChildren = null;
        //... no more attributes.
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:58:13+00:00Added an answer on May 22, 2026 at 5:58 pm

    In the code for saving the serializable, where is the exception handled?

    I think its safe to assume, because you can’t read the file, that an exception was raised while the file was being written. It is doubtful, in my mind, that you will be able to recover the file if you simply closed the outputstream after encountering an error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it practical / possible to use serialization to read data from an RSS
Related: How can I use polymorphism in XML Serialization? I have a class I
We use .net binary serialization right now to serialize data to persist. It does
I'm trying to use the native flex serialization/deserialization process to save/load state of a
I've written a custom serialization routine that does not use ISerializable or the SerialzableAttribute
I am developing an interface-driven serialization framework for use with interfaces for data XML
I save data using binary serialization. Now I have changed a field in the
I am trying to learn to use C# serialization as a way to save
I'm using serialization for save feature in my application. But when the data is
We use BinaryFormatter in a C# game, to save user game progress, game levels,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.