android中的FTPClient将图像转换为位图
救命!!我已经安装了ApacheComons.net FTPClient。因为我需要通过ftp下载PNG文件。流下载,但我有麻烦将其转换成位图,以便我可以保存到本地存储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
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协议用于传输文件。所以没有什么比直接将文件下载到磁盘更简单的了。谢谢,我没想到