Jump to content

Class for file saves


Ridiculousness

Recommended Posts

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 by Ridiculousness
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...