0

I have below class.

public class Gettype {

    public static void main(String[] args) throws IOException, ParseException {

         URL url = new URL("http://static.ddmcdn.com/gif/recipes/octo-arm-150513 200x200.jpg");
         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
         connection.setRequestProperty(
                "User-Agent",
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31");

         connection.getInputStream();

    }

It throws FileNotFoundException. But when I access the same URL (http://static.ddmcdn.com/gif/recipes/octo-arm-150513 200x200.jpg) through browser, it works. Please help me.

4
  • I can not accedd the Image with this URL http://static.ddmcdn.com/gif/recipes/octo-arm-150513200x200.jpg Are you sure file is really exist ? Commented May 19, 2015 at 5:42
  • do you want to store the file local system ? Commented May 19, 2015 at 5:42
  • There is space before 200x200.jpg. Url is static.ddmcdn.com/gif/recipes/octo-arm-150513 200x200.jpg Commented May 19, 2015 at 5:43
  • When you ask about an exception, always post the exact and complete stack trace in the question. I also get a 404 not found on this URL. Commented May 19, 2015 at 5:45

1 Answer 1

1

Your URL is "http://static.ddmcdn.com/gif/recipes/octo-arm-150513%20200x200.jpg"

replace empty with %20

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.