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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:50:39+00:00 2026-06-05T11:50:39+00:00

simply i need to download an image but the problem is the image get

  • 0

simply i need to download an image but the problem is the image get corrupted !!!
i find many way to download the image but still this problem appeared .

i try do this :

File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File file2 = new File(path,"DemoPictureX.png");
InputStream is=(InputStream) new URL("http://androidsaveitem.appspot.com/downloadjpg").getContent();
OutputStream os = new FileOutputStream(file2);
byte[] data = new byte[is.available()];
is.read(data);
os.write(data);

is.close();
os.close();

i think it read just read some row from the image !!!

  • 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-05T11:50:40+00:00Added an answer on June 5, 2026 at 11:50 am

    you need a loop and read with a smaller buffer (like 1024 bytes) from the stream.

      URL url = new URL("your url here");
      URLConnection connection = url.openConnection();
      InputStream is = connection.getInputStream();
      BufferedInputStream bis = new BufferedInputStream(is);
      FileOutputStream fos = new FileOutputStream(targetFile);
      byte buffer[] = new byte[1024];
      int read;
      while ((read = bis.read(buffer)) > 0) {
        fos.write(buffer, 0, read);
      }
      fos.flush();
      fos.close();
      bis.close();
      is.close();
    

    This should work for you

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

Sidebar

Related Questions

I need to simply read an .xml file; like this: <exchanges> <exchange> <timestamp>2010-08-19 17:15:56</timestamp>
All I need to do is download some basic text-based and image files from
I'm trying to get a bunch of div's to wrap around an image, but
I'm sorry if this subject has already been answered, but I couldn't find what
I need a simple script that will download a image file to the user's
I need a simple proxy PHP function/script that can download a file from a
I simply need to add floatArray1 to floatArray2 storing the result in floatArray2.. no
Simply I need to write echo t${count} = $t${count} To a text file, including
I need to simply provide the content of a property to a custom User
I need to simply copy copy images (ul>li>img) from one container to other with

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.