누군가가 아래 코드를 확인하고 수행해야 할 일이 있는지 확인할 수 있습니까? 내가 정말로 걱정하고있는 것은 성능입니다. 그렇지 않다면 코드 가독성을 개선하기 위해 더 잘 수행 할 수있는 것이 있습니까?URL에서 이미지 읽기 - 성능 문제가 있습니까?
try {
URL url = new URL("http://www.pudim.com.br/SiteBuilder/UploadUsers/pudim.com.br/pudim.jpg");
URLConnection uc = url.openConnection();
String type = uc.getContentType();
BufferedImage image = ImageIO.read(url);
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", os);
byte[] bytes = os.toByteArray();
InputStream is = new ByteArrayInputStream(bytes);
// not important :) ...
} catch (AmazonServiceException e) {
e.printStackTrace();
} catch (AmazonClientException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
모든 사항을 환영합니다.
감사합니다.
왜 이미지를 읽고 쓰는데'ImageIO'를 사용하고 있습니까? 왜 그냥 URLConnection의'InputStream'을 사용하여 내용을 읽지 않는가? – MadProgrammer