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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:52:15+00:00 2026-05-28T05:52:15+00:00

I have an application where i download images from a server and display them

  • 0

I have an application where i download images from a server and display them in a imageview. This works the majority of the time but not always. It seems the times it doesn’t work is when there are spaces in the url. The error i get is

java.lang.RuntimeException: java.io.FileNotFoundException:

I have tried a number of different ways to try and encode the url but have had no success upto now.

Here is the class I am using.

private URL url;
Bitmap bitmap;

public ImageDownloader() {

}//constructor


public Drawable getImage(String urlString) throws IOException{
    Log.i("url", urlString);
    url = new URL(urlString);
    InputStream is = url.openStream();
    Bitmap bitmap = BitmapFactory.decodeStream(new FlushedInputStream(is));
    Drawable image = new BitmapDrawable(bitmap);
    return image;

 }//getImage

static class FlushedInputStream extends FilterInputStream {
    public FlushedInputStream(InputStream inputStream) {
        super(inputStream);
    }

    @Override
    public long skip(long n) throws IOException {
        long totalBytesSkipped = 0L;
        while (totalBytesSkipped < n) {
            long bytesSkipped = in.skip(n - totalBytesSkipped);
            if (bytesSkipped == 0L) {
                  int bytee = read();
                  if (bytee < 0) {
                      break;  // we reached EOF
                  } else {
                      bytesSkipped = 1; // we read one byte
                  }
           }
            totalBytesSkipped += bytesSkipped;
        }
        return totalBytesSkipped;
    }
}


public Bitmap getBitmap(String urlString) {
    try {
        //String s = Uri.encode(urlString);
        url = new URL(urlString);
    } catch (MalformedURLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    HttpURLConnection conn = null;
    try {
        conn = (HttpURLConnection) url.openConnection();
           conn.setRequestProperty("User-agent", "Mozilla/4.0");
           conn.connect();

    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    InputStream in = null;
    try {
        in = conn.getInputStream();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return bitmap = BitmapFactory.decodeStream(in);



}

Both the getImage and getBitmap have the same error.

Here is an example of a url i am using.

http://kaiorize-clone1.loomarea.com/sites/default/files/imagecache/app_product_full/sites/default/files/BsfL_Logo_final_sonderfarben 300dpi.jpg

  • 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-28T05:52:15+00:00Added an answer on May 28, 2026 at 5:52 am

    This was a strange one. I tried to encode the normal way but I was still getting the same error. I check the URL that was being sent and the space had been changed for a “%20”. In the end through desperation I decided to just change the space into “%20” myself instead of encoding. This solved the problem. Not the most elegent of solutions but it worked!

            String url1 = json.getString("app_imagepath");
            String url = url1.replace(" ", "%20");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application we have to download around 10 Images from server and display
I have a script that download's files from a server, all works nice. But
I have a desktop application that needs to upload/download images to/from service computer over
I have an application that allows the user to download a csv. This works
I have an iPhone application where i download information from the internet and put
In my Android Application i have to download video from Amazon bucket. When I
I have prepared one sample application.When application install in devices download the file from
how to download a image from a web server to java SE application. i
I want to download a file from server to a local host. i have
I am using Lazy loading in my application.I want to Download images from url

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.