Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java download image file

(throws IOException)

Image image = null;
try {
    URL url = new URL("http://www.yahoo.com/image_to_read.jpg");
    image = ImageIO.read(url);
} catch (IOException e) {
}
Comment

java download image file

 URL url = new URL("http://www.yahoo.com/image_to_read.jpg");
InputStream in = new BufferedInputStream(url.openStream());
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int n = 0;
while (-1!=(n=in.read(buf)))
{
   out.write(buf, 0, n);
}
out.close();
in.close();
byte[] response = out.toByteArray();
Comment

java download image file

URL url = new URL("http://upload.wikimedia.org/wikipedia/commons/9/9c/Image-Porkeri_001.jpg");
InputStream in = new BufferedInputStream(url.openStream());
OutputStream out = new BufferedOutputStream(new FileOutputStream("Image-Porkeri_001.jpg"));

for ( int i; (i = in.read()) != -1; ) {
    out.write(i);
}
in.close();
out.close();
Comment

PREVIOUS NEXT
Code Example
Java :: java csv line split 
Java :: int array java 
Java :: setting scale to big decimal java 
Java :: How to perform quick sort, in Java? 
Java :: java print array backwards 
Java :: next greater permutation leetcode 
Java :: how to assert that an exception is thrown java 
Java :: jpa enum as string 
Java :: pivot in array 
Java :: uuid from any string java 
Java :: compare two times in java 
Java :: c# or java 
Java :: joining an array of strings in java 
Java :: random boolean java 
Java :: fill two dimensional array column by column java 
Java :: java enums 
Java :: java extract zip 
Java :: iterate thrpugh hasmap 
Java :: java string to double comma 
Java :: check if list includes value java 
Java :: java read file 
Java :: list of numbers java 
Java :: java throw keyword 
Java :: java long to hours minutes and seconds 
Java :: variables java 
Java :: multiplication program java 
Java :: how to find palindrome numbers in java 
Java :: convert char array to set in java 
Java :: HttpContext.GetOwinContext().Authentication.SignOut 
Java :: array contain java 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =