は、私は、高速文字列にインストリームに変換するにはどうすればよい今..インストリームを文字列をより速く変換する(Android)?
private static String convertStreamToString(InputStream is) {
/*
* To convert the InputStream to String we use the BufferedReader.readLine()
* method. We iterate until the BufferedReader return null which means
* there's no more data to read. Each line will appended to a StringBuilder
* and returned as String.
*/
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
を使用してイムしかし、これはエミュレータ上の少なくとも2〜3分かかります。私はインストリームをバイト配列に変換してから文字列に変換すれば高速になることがわかった。誰にもこれについての知識はありますか?
@Philip どうすればよいですか? – user758114