Created
June 25, 2012 13:54
-
-
Save phl0w/2988771 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Image img; | |
| ... | |
| @Override | |
| protected void setup() { | |
| img = getImage("http://website.com/image.png", "image.png"); | |
| } | |
| ... | |
| private Image getImage(String url, String name) { | |
| try { | |
| File dir = new File(System.getProperty("file.seperator") + name); | |
| if (!dir.exists()) { | |
| ImageIO.write(ImageIO.read(new URL(url)), | |
| url.substring(url.lastIndexOf('.')).substring(1), dir); | |
| } | |
| return ImageIO.read(dir); | |
| } catch (Exception a) { | |
| a.printStackTrace(); | |
| } | |
| return null; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment