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 8282827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:30:55+00:00 2026-06-08T10:30:55+00:00

My app writes loads of bytes constantly to a file. If a block of

  • 0

My app writes loads of bytes constantly to a file. If a block of my code is writing out bytes and gets an IOException if the connection to the drive or network is lost how am I to know how many bytes it has written?

For eg I’m writing 2500 bytes at a time and if an IOException occurs does it mean it wrote nothing to the file or it would have written partial bytes to the file? If partial bytes are written to the file how am I to know how much is written

FYI I’m using

DataOutputStream

to write out files. I flush only when my app closes.

  • 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-08T10:30:57+00:00Added an answer on June 8, 2026 at 10:30 am

    You can’t, IOException can happen at any time. If you think about it, IOException can be caused by software or hardware failure at any time, before the first byte was written, after all were written but something happened to the connection – or in the middle if the data chunk was pretty big.

    After reconnecting you must check the file size or use some other technique to keep files in consistent state and recover. The simplest safety net: read file size before writing data and store it reliably, write the data and read file size after writing. If error occurrs and current file size is not equal to expected file size (last saved), truncate extra bytes and retry.

    Read about transaction logs in relational databases to see how big and reliable software handles such cases.

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

Sidebar

Related Questions

I'm working on an app that writes data out to a .plist from a
Our Java app writes to MQ Series queues via a Weblogic JMS Message Bridge.
I have a Rails app that has 2 clients -- an iOS app reads/writes
am working on a java(tomcat) app. that sometimes writes to stdout. But I notice
Problem: I am trying to write an app that executes some code when the
My problem is that I have an app which is writing a lot of
I'm writing an app that's destined for the browser, and I want to write
I'm building a Mango app that writes data to a SqlCe database; I have
I have a Sencha Touch App that loads data from a REST service into
I have this code to store a remote sqlite .db file with my android

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.