gpt4 book ai didi

android - java.io.FileNotFoundException 尝试加载我刚刚保存的文件时

转载 作者:行者123 更新时间:2023-11-30 04:48:29 25 4
gpt4 key购买 nike

我正在尝试保存并加载刚刚保存的文件,但我找不到它。

我知道它正在保存,因为我可以在应用程序的“管理应用程序”屏幕下查看缓存大小,并看到在保存图像时大小增加了。

这是我遇到的错误:java.io.FileNotFoundException:/data/data/com.xxxxx/files/5ec2d71d-8a99-4258-a33a-91f6f99b8f0e.jpg

这是我的代码:

imageDir = new File(context.getCacheDir().getAbsolutePath());
String newName = UUID.randomUUID().toString() + ".jpg";
Bitmap bmp = ImageLoader.getInstance().getBitmap(e.getUrl());


Boolean r = imageDir.exists();
Boolean c = imageDir.canWrite();
String[] d = imageDir.list();

BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(imageDir + "/" + newName));
bmp.compress(CompressFormat.JPEG, 90, out);
out.flush();
out.close();

d = imageDir.list();

FileInputStream fis = new FileInputStream(imageDir + "/" + newName);
ObjectInputStream ois = new ObjectInputStream(fis);
Bitmap b = (Bitmap) ois.readObject();

想法?

最佳答案

Context.openFileInput 打开应用数据目录中的文件。无论如何,那个电话有什么意义?您已经创建了一个 FileInputStream

关于android - java.io.FileNotFoundException 尝试加载我刚刚保存的文件时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4229943/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com