Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中的FTPClient将图像转换为位图_Android_Bitmap_Ftp_Apache Commons Net - Fatal编程技术网

android中的FTPClient将图像转换为位图

android中的FTPClient将图像转换为位图,android,bitmap,ftp,apache-commons-net,Android,Bitmap,Ftp,Apache Commons Net,救命!!我已经安装了ApacheComons.net FTPClient。因为我需要通过ftp下载PNG文件。流下载,但我有麻烦将其转换成位图,以便我可以保存到本地存储 mFTPClient.connect("path"); mFTPClient.login("anonymous","nobody"); mFTPClient.enterLocalPassiveMode(); mFTPClient.changeWorkingDirec

救命!!我已经安装了ApacheComons.net FTPClient。因为我需要通过ftp下载PNG文件。流下载,但我有麻烦将其转换成位图,以便我可以保存到本地存储

        mFTPClient.connect("path");
        mFTPClient.login("anonymous","nobody");
        mFTPClient.enterLocalPassiveMode();
        mFTPClient.changeWorkingDirectory("/fax");
        InputStream inStream = mFTPClient.retrieveFileStream("nweimage.PNG");
        InputStreamReader isr = new InputStreamReader(inStream, "UTF8"); 
一直在尝试使用BitmapFactory来转换它,但总是得到null返回

有什么建议吗


干杯

我就是这样度过的。感谢greenapps让我想到了另一条路

     mFTPClient.connect("path");
        mFTPClient.login("anonymous","nobody");
        mFTPClient.enterLocalPassiveMode();
        mFTPClient.changeWorkingDirectory("/fax");
        mFTPClient.setControlEncoding("UTF-8");
        mFTPClient.setFileType(FTPClient.BINARY_FILE_TYPE);
    try{
            FileOutputStream out = new FileOutputStream(file);

            boolean status = mFTPClient.retrieveFile("image.PNG", out);
            out.flush();
            out.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

为什么要先将png文件转换为位图?您正在使用ftp组件。FTP协议用于传输文件。所以没有什么比直接将文件下载到磁盘更简单的了。谢谢,我没想到