Pour la deuxieme méthode il vaut mieux faire:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
public static int concatenateStreams(FileOutputStream out, InputStream... ins) throws IOException
{
int total = 0;
byte[] buffer = new byte[BUFFER_SIZE];
for (InputStream in : ins) {
int avail;
in.read(buffer);
while ((avail = in.read(buffer)) > 0) {
out.write(buffer, 0, avail);
total += avail;
}
}
return total;
} |
Et c'est dans la seconde qu'il faudrait logger l'exception...
Et surtout pas avec:
Log.i(TAG, " exception " + e.getMessage());
qui perd tout un tas d'information mais par:
Log.e(TAG, "Echec écriture du fichier",e);
qui non seulement affichera l'exception (getMessage() peut être vide), mais aussi toute la stack au moment ou celle-ci a eu lieu.
Partager