跟着视频自学HttpUrlConnection时,练习把图片缓存到系统cache目录下,
这么写没有问题,可以在cache下找到图片文件;
File file = new File(getCacheDir(), "test.png");
加密后就报错了
File file = new File(getCacheDir(), Base64.encodeToString(path.getBytes(), Base64.DEFAULT));
java.io.FileNotFoundException: /data/data/.../cache/aHR0cHM6Ly93d3cuYmFpZHUuY29tL2ltZy9iZF9sb2dvMS5wbmc/d2hlcmU9c3VwZXI=
: open failed: ENOENT (No such file or directory)
报错部分代码如下,在创建输出流这一行报错了
if (code == 200) {
InputStream in = conn.getInputStream();
FileOutputStream fos = new FileOutputStream(file);
int len = -1;
byte[] buffer = new byte[1024];
while ((len = in.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
...
请问各位大神问题出在哪里