public static void main(String...args) throws Exception{
URL url = new URL("http://code.jquery.com/ui/1.11.2/themes/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
InputStream inputStream = conn.getInputStream();
byte[] getData = readInputStream(inputStream);
File imageFile = new File("D:/aaa/ui-bg_flat_0_aaaaaa_40x100.png");
FileOutputStream fos = new FileOutputStream(imageFile);
fos.write(getData);
fos.close();
System.out.println(" read picture success");
byte[] buffer = new byte[1024];
int len = 0;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
while((len = inputStream.read(buffer)) != -1) {
bos.write(buffer, 0, len);
}
bos.close();
return bos.toByteArray();
}
URL url = new URL("http://code.jquery.com/ui/1.11.2/themes/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
InputStream inputStream = conn.getInputStream();
byte[] getData = readInputStream(inputStream);
File imageFile = new File("D:/aaa/ui-bg_flat_0_aaaaaa_40x100.png");
FileOutputStream fos = new FileOutputStream(imageFile);
fos.write(getData);
fos.close();
System.out.println(" read picture success");
}
byte[] buffer = new byte[1024];
int len = 0;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
while((len = inputStream.read(buffer)) != -1) {
bos.write(buffer, 0, len);
}
bos.close();
return bos.toByteArray();
}