我有一个已发布的具有 HTTP 音频下载过程的 Android 应用程序。
直到今天,这个处理都很好。
我的代码有什么问题?
final URL downloadFileUrl = new URL(mPerformanceSong.getPreviewUrl());
final HttpURLConnection httpURLConnection = (HttpURLConnection) downloadFileUrl.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setDoOutput(true);
httpURLConnection.setConnectTimeout(10000);
httpURLConnection.setReadTimeout(10000);
httpURLConnection.connect();
mTrackDownloadFile = new File(RecordPerformance.this.getCacheDir(), "mediafile");
mTrackDownloadFile.createNewFile();
final FileOutputStream fileOutputStream = new FileOutputStream(mTrackDownloadFile);
final byte buffer[] = new byte[16 * 1024];
final InputStream inputStream = httpURLConnection.getInputStream();
int len1 = 0;
while ((len1 = inputStream.read(buffer)) > 0) {
fileOutputStream.write(buffer, 0, len1);
}
fileOutputStream.flush();
fileOutputStream.close();
下载文件的内容似乎是 gzip。
这是否意味着我需要将 inputStream 包装在 GZIPInputStream 中?
示例下载 URL 是
http://www.amazon.com/gp/dmusic/get_sample_url.html?ASIN=B008TMSNMI