我正在从 SQL 数据库下载安卓设备上的图片;一切正常,除了打开 Stream 需要很长时间(即使没有图片可下载)。在实际下载开始之前大约需要 5 秒。这是我的代码片段:
URL url = new URL(sUrl[0]);
URLConnection connection = url.openConnection();
connection.connect();
int fileLength = connection.getContentLength();
//input = connection.getInputStream();
InputStream input = new BufferedInputStream(url.openStream());
File file = new File(
Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
"MyCameraApp" + "/testpic.jpg");
OutputStream output = new FileOutputStream(file);
byte data[] = new byte[1024];
//---blabla progressbar update etc..
这条线InputStream input = new BufferedInputStream(url.openStream());
给出了问题。关于如何加快速度的任何想法?