I get the file here's a piece of the function
while ((bytesRead = is.read(data)) > 0) { try { sb.append(new String(data, 0, bytesRead, charset)); } catch (UnsupportedEncodingException e) { Log.e(MY_LOG, "Invalid charset: " + e); //Append without charset (uses system's default charset) sb.append(new String(data, 0, bytesRead)); } } And I always get into the catch (UnsupportedEncodingException e) . But the file is recorded and everything is fine ...
What does this charset mean? I understand this is the encoding ...
But how scary are I recording without her?
This is the way to get this encoding.
String[] values = conn.getContentType().split(";"); String charset = ""; for (String value : values) { value = value.trim(); if (value.toLowerCase().startsWith("charset=")) { charset = value.substring("charset=".length()); break; } } I understand that if the server sent me a file with an encoding, then I read it and write the file with the same encoding ...
charsetbefore callingsb.append(new String(data, 0, bytesRead, charset));? - Vladyslav MatviienkoString charset = "";I understand it because the server does not transmitcharset... Could this be? - Aleksey Timoshchenkoconn.getContentType(). You know better if your server can not give the charset. - Vladyslav MatviienkoString[] valuescontain only the first cell withapplication/textvalue ... - Aleksey Timoshchenko