Saving an Image Locally in Codename One Project

半世苍凉 提交于 2019-11-30 20:43:20

The src folder doesn't exist on your device and you don't have access to the "application folder" (where the native binaries are stored) otherwise you would be able to change your application on the device potentially installing a virus.

The variable i in your example is a temporary file URL that you can see on your PC/Mac. You should copy it to a local file or to local storage.

You can open an input stream to the image using FileSystemStorage, you can then store it using that same class (e.g. in the application home directory) or you can use the Storage class to save the image somewhere.

E.g. you can copy image to local storage as such:

InputStream stream = FileSystemStorage.getInstance().openInputStream(i);
OutputStream out = Storage.getInstance().createOutputStream("MyImage");
Util.copy(stream, out);
Util.cleanup(stream);
Util.cleanup(out);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!