当我使用 android 设备拍摄图像时,我使用的是 Oracle MAF 2.1.0.0.41,我看到这个图像的路径是:file:/storage/emulated/0/Android/data/com.example.app /142416553.jpg
我尝试使用 java bean 类访问此图像:
try {
Object imageSource = (Object) AdfmfJavaUtilities.evaluateELExpression("#{bindings.Return.inputValue}");
String path = (String) imageSource;
path = "***path: " + path;
File f = new File(path);
path = path + f.exists() + f.canRead() + f.canWrite() + " "+imageSource.getClass();
InputStream is = new BufferedInputStream(new FileInputStream(path));
InputStreamReader rdr = new InputStreamReader(is, "UTF-8");
StringBuilder contents = new StringBuilder();
char[] buff = new char[4096];
int len = rdr.read(buff);
while (len >= 0) {
contents.append(buff, 0, len);
}
System.out.println("***Output: " + buff.toString());
image = buff.toString();
} catch (FileNotFoundException e) {
image =" ***Error FileNotFoundException: " + e.getMessage();
} catch (IOException e) {
image = "***Error IOException: " + e.getMessage();
} catch (Exception e) {
image = "***Error Exception: " + e.getMessage();
}
但我遇到了这个错误:没有这样的文件或目录不能读、写和不存在。
谁能帮我!如何从缓存目录中读取图像。