Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting a Web Image

Status
Not open for further replies.

developer155

Programmer
Jan 21, 2004
512
US
I need to get an image from the web (I know url) and use Java to create HTML file and display that image. So what I am doing is establishing the connection to the Web in the program and connecting to the image URL. Now I guess I would need to get the source for that image into a buffer I guess. Is there any way to do this? Also, is there a better way to copy an image from web page when I know the url?

thanks
 
hi

i don't know is there any special method to get image from url.

you may try to find image src from url.
Code:
int i = htmlInYourUrl.indexOf("src"); //gives index of first src found in html

and read the image just like a file you read from your local disc.
or like how you read html text from url.
 
How can I get the string of the web page sourcew with Java?

thanks
 
hi

this may help you

Code:
URL url = new URL(strUrl);
URLConnection uc = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
String strInputLine = new String();
while ((strInputLine = in.readLine()) != null){
  strRetVal = strRetVal + strInputLine;
}
in.close();
return strRetVal;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top