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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:48:09+00:00 2026-06-06T13:48:09+00:00

I am trying to save a file (and then read it later) in java

  • 0

I am trying to save a file (and then read it later) in java (android) using the following

FileInputStream fis = openFileInput(filename);

and then maybe use BufferedReader/writer. Anyways, I am trying to save String and numbers and I was wondering what would be the best method to write and read from I/O for such case?
I was about to do the following for reading

FileInputStream fis = openFileInput(filename);
InputStreamReader inputStreamReader = new InputStreamReader(fis);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

and for writing

FileOutputStream fos = openFileOutput(filename, 20);
OutputStreamWriter outStreamReader = new OutputStreamWriter(fos);
BufferedWriter bufferedWriter = new BufferedWriter(outStreamReader);

but I noticed that the readLine will always return string of the line. so I have to go throught the conversion of Strings to Integer for some lines. Is this an efficient way of doing it (or correct way)? I feel I am missing something
Thank you

  • 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-06T13:48:12+00:00Added an answer on June 6, 2026 at 1:48 pm

    Unless you have multiple-line strings or strings that can be mistaken for integers or a file with a very complex structure, just write the text file as proposed above. The inefficiency is not worth losing the benefit of portability and readability.

    Other good options for more complex files are JSON or XML or Java properties files (for which good libraries exist that you can use).

    Only go to a binary format if you have a really good reason (and having to call Integer.parseInt and saving 3 bytes is not a good reason).

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

Sidebar

Related Questions

I'm trying to encrypt a string, save it in a file and then later
I'm trying to save some data to A file in android, I'm using herefor
I'm trying to save a huge NSArray to a file and then retrieve it...
I'm trying to save a file in a subdirectory in Android 1.5. I can
I am getting the following error when trying to save a file to disk:
I'm trying to simply save a file. However, I need a filename entered without
I was trying to save one of the class object to a File using
am trying to read a file (double values) with scanner and save the data
I'm trying to save the contents of an object into a file, and then
I'm trying to read .xlsm file using Apache POI library (3.8-beta5): Workbook wb =

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.