我正在使用以下代码将文件从API调用保存到本地设备存储
InputStream inputStream = httpResponse.getEntity()
.getContent();
if (null != inputStream) {
File file = new File(path + filename);
FileOutputStream fos = new FileOutputStream(file);
// Save the file locally.
IOUtils.copy(inputStream, fos);
// Close both streams
fos.close();
inputStream.close();
Log.d(TestActivity.LOG_TAG, filename + " saved successfully: " +
Boolean.toString(file.isFile()));
}
它将文件保存到给定路径中的设备存储,但文件已损坏。