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

  • Home
  • SEARCH
  • 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 8458811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:10:47+00:00 2026-06-10T13:10:47+00:00

I am unable to write the ArrayList to a file. I am doing as

  • 0

I am unable to write the ArrayList to a file. I am doing as following, what is the correct way?
If I don’t add ‘pt’ into arraylist, process goes fine and it gets saved.
os.writeObject(arr); – after this line debugger goes to IOException. Code:

//holder class implements Serializable
transient ArrayList<Point> arr;
transient Point pt;
//I've tried without transient, same result 
//
arr = new ArrayList<Point>();
pt = new Point();
p.x = 10;
p.y = 20;
arr.add(pt);
//If I don't add 'pt' into arraylist, process goes fine and it gets saved.
//
String strStorageDirectory = this.getFilesDir() + "/DataFiles";
final File DataStorageDirectory = new File(strStorageDirectory);
File lfile = new File(DataStorageDirectory, "samplefile.bin");
FileOutputStream fos;
    try {
        fos = new FileOutputStream(lfile);
        ObjectOutputStream os = new ObjectOutputStream(fos);
        os.writeObject(arr);//after this line debugger goes to IOException
        //I've tried with os.writeObject((Serializable)arr), same result;
        os.flush();//I've tried removing it, same result
        os.close();
        fos.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
  • 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-06-10T13:10:49+00:00Added an answer on June 10, 2026 at 1:10 pm

    Instead of keeping Points in ArrayList, you can add two Integers per point. Integer supports Serializable, Point does not.

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

Sidebar

Related Questions

well I'm unable to write file if application Run auto at start-up but when
I am unable to write a stored procedure for bulk insertion into my table.
My php script is unable to write a file despide 777 permission. the file
I'm unable to execute the following prepared statement , PREPARE stmt FROM 'SELECT sb.id,sb.category,sb.make,sb.name,sb.pic,rs.slot
I am getting a Unable to load the requested file: default.php error in codeigniter
I am using SqlBulkCopy object to write a datatable into an sql server table.
i am unable to write log any info, error, debug using log4net, i tried
I am using streamwriter to write a string into stream. Now when I access
I'm unable to write a custom urllib.FancyURLopener which initializes the user and passwd values
I have written code for many patterns but unable to write for this..... not

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.