I am writing to a file using the following code:
File file = new File(getCacheDir(), "cachefile");
FileOutputStream fos = new FileOutputStream(file);
StringBuilder cachetext = new StringBuilder();
Iterator bri = brands.iterator();
Iterator bli = brand_id.iterator();
while(bli.hasNext()) {
cachetext.append(bli.next() + "|" + bri.next() + System.getProperty("line.separator"));
}
fos.write(cachetext.toString().getBytes());
fos.close();
This works fine - there are no errors, and the file ends up with what I expect from it. However, when I read it through openFileInput (), I get an exception saying that path separators are not allowed
FileInputStream fis = openFileInput(getCacheDir() + "/cachefile");
Fairly honest, containing a slash, but how else can I specify the path to the file I want to open? Of course, there must be a way to do this, but I canβt find the answers through Google (βreadβ, βcacheβ and βfileβ are not the most niche conditions ...), so I thought that I would try a human look. Thanks in advance!
source
share