Java Download Image that aspx file returns.

D

Domenick

I am trying to save an image from a URL to disk, but I am not having
any luck. The URL of the image is:

http://www.bungie.net/Stats/halo2emblem.ashx?s=90&0=1&1=0&2=11&3=0&f=6&b=0&fl=1

The problem is that if you copy/paste the line above into your browser,
you will get a blank HTML page, but if you create a html file like
this:
<html>
<head>
<title></title>
</head>
<body>
<img
src="http://www.bungie.net/Stats/halo2emblem.ashx?s=90&0=1&1=0&2=11&3=0&f=6&b=0&fl=1">
</body>
</html>

The image comes up fine. I am not that familiar with .net (I believe
that is what the .aspx refers to) and I was wondering if there was any
way to stream the bitmap returned from that url to disk. Any help
would be appreciated. Thanks in advance.

- Domenick
 
A

Andrey Kuznetsov

I am trying to save an image from a URL to disk, but I am not having
any luck. The URL of the image is:

http://www.bungie.net/Stats/halo2emblem.ashx?s=90&0=1&1=0&2=11&3=0&f=6&b=0&fl=1

The problem is that if you copy/paste the line above into your browser,
you will get a blank HTML page

Firefox shows image.
The image comes up fine. I am not that familiar with .net (I believe
that is what the .aspx refers to) and I was wondering if there was any
way to stream the bitmap returned from that url to disk

String urlString =
"http://www.bungie.net/Stats/halo2emblem.ashx?s=90&0=1&1=0&2=11&3=0&f=6&b=0&fl=1";
URL url = new URL(urlString);
InputStream in = url.openConnection().getInputStream();

then read data from InputStream and write to disk or wherever.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top