Ridiculousness Posted August 29, 2014 Share Posted August 29, 2014 (edited) I'm reading an image off of the internet and trying to write it to the user's computer and then read it in future script runs. Is there a class where I can get the storage directory? I'm having trouble writing to their files this used to be my code for it: public static void saveImages() { for (String s : urls) { try { String[] string = s.split("/"); String[] name = string[5].replace(".", "/").split("/"); File outPutFile = new File(Environment.getStorageDirectory() + File.separator + name[0] + ".png"); if (!outPutFile.exists()) { RenderedImage img = getImage(s); ImageIO.write(img, "png", outPutFile); } } catch (IOException e) { } } } public static void loadImage(int idx) { String[] string = urls[idx].split("/"); String[] name = string[5].replace(".", "/").split("/"); File inPutFile = new File(Environment.getStorageDirectory() + File.separator + name[0] + ".png"); if (inPutFile.exists()) { try { images[idx] = ImageIO.read(inPutFile); } catch (IOException e) { e.printStackTrace(); } } } Edited August 29, 2014 by Ridiculousness Link to comment Share on other sites More sharing options...
Botre Posted August 29, 2014 Share Posted August 29, 2014 private String separator = System.getProperty("file.separator"); private String directoryOSBot = System.getProperty("user.home") + separator + "OSBot" + separator; Link to comment Share on other sites More sharing options...
Ridiculousness Posted August 29, 2014 Author Share Posted August 29, 2014 private String separator = System.getProperty("file.separator"); private String directoryOSBot = System.getProperty("user.home") + separator + "OSBot" + separator; Thank you! Link to comment Share on other sites More sharing options...