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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:17:47+00:00 2026-05-25T11:17:47+00:00

I am doing a rest call and getting a json file from the server

  • 0

I am doing a rest call and getting a json file from the server by this

HttpGet httpget = new HttpGet("someurl");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
InputStream source = entity.getContent();

now i want to store this into a local file I am using FileOutputStream to do this but the problem is how to effectively convert the inputstream to outputstream if i am using something like this

FileOutputStream fos = openFileOutput(filename,Context.MODE_PRIVATE);

            int nextChar;
            while ((nextChar = source.read()) != -1) {
                fos.write((char) nextChar);
                System.out.println((char) nextChar);
                fos.flush();
            }

it is storing very slow the file which i am getting is upto 100kb is there any other faster method or any other way which i can use to store the json file in my device?

My applications uses this json heavily and i don’t want to call the REST each time.

thanks
Pranay

  • 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-25T11:17:48+00:00Added an answer on May 25, 2026 at 11:17 am

    try to use org.apache.commons.io.IOUtils’s

        IOUtils.copy(is,fos); 
    

    lets see, what happening. Thanks,

    EDIT: Why not you are use sqlite database? parse JSON result onetime and insert it in database only onetime stuff then always you get fast execution.

    EDIT: try android’s internal storage for write json file

      try {      
           FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_APPEND);
            fos.write(myJSONString.getBytes());
             fos.close();      
           //Log.d(TAG, "Written to file");  
         } 
       catch (Exception e)
         {    
            Log.d(TAG, "cought");     
             e.printStackTrace(); 
          } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am doing a GET(REST) and using InternetReadFile API to read response which is an
Does anyone know if (and how) I can build an application (Java/Ruby/whatever) doing REST
I understand how to use REST for doing general entity interactions - using urls
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
I am trying to mock the following call: s.socket().bind(new InetSocketAddress(serverIPAddress_, serverPort_), 0); so I
I'm doing some simple client side validation with jQuery. var passedValidation = new Boolean(true);
I am running an Apache 2.2.3 proxy server to hide my backend machines from
Part 1: I have a call to layout(:default){|path,wish| wish !~ /rss|atom|json/} but requests to
Hey, I am doing to AJAX call to flickr.interestingness.getList to get the interesting pictures
The Problem Drupal 6.22 install with REST server and Services modules. I do a

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.