【问题标题】:Save file object to internal storage as image将文件对象作为图像保存到内部存储
【发布时间】:2015-03-09 05:15:49
【问题描述】:

我正在使用 loopj 库 https://github.com/loopj/android-async-http 通过 URL 下载图像。作为回应,我将图像作为文件对象。我想将此图像作为 .jpg 存储到我的内部存储中并获取该图像的路径。有人可以帮我解决这个问题吗?或者向我推荐任何其他库或可以实现此功能的代码?

【问题讨论】:

    标签: android android-file loopj


    【解决方案1】:

    试试:

    try {
            File imgFile = null; //File you received from loopj
            FileInputStream fis = new FileInputStream(imgFile);
            FileOutputStream fos = new FileOutputStream(
                    new File("yourPath.jpg"));
            byte fileContent[] = new byte[(int) imgFile.length()];
            fis.read(fileContent);
            fos.write(fileContent);
            fis.close();
            fos.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-28
      • 1970-01-01
      • 2023-03-10
      • 2016-08-06
      • 1970-01-01
      • 1970-01-01
      • 2012-03-16
      相关资源
      最近更新 更多