The problem is that when you download a normal file, instead of the expected music, the glitch'anuta version is saved: with extraneous whistles and sudden changes in the tempo of the song.
The downloaded file is different from the original chaotic interspersed characters '?'. Otherwise, they are identical. It would seem that there are no obvious problems with the encoding.
Methods Saving to file:
public static void Save(String content, String filePath, String charset) { try { File file = new File(filePath); file.getParentFile().mkdirs(); charset = charset != null ? charset : Charset.defaultCharset().name(); //здесь windows-1251 Writer bw = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file), charset)); bw.append(content); bw.flush(); bw.close(); } catch(Exception e) { } }
Download:
public String getString(String urlAdress, String charset) { try { URL url = new URL(urlAdress); URLConnection connection = url.openConnection(); charset = charset != null ? charset : Charset.defaultCharset().name(); //здесь windows-1251 InputStream is = (InputStream) connection.getContent(); Reader reader = new BufferedReader(new InputStreamReader(is, charset)); StringBuffer content = new StringBuffer(); char[] bufferChars = new char[1024]; int bufferSize; while ((bufferSize = reader.read(bufferChars)) != -1) { content.append(bufferChars, 0, bufferSize); } return content.toString(); } catch(Exception e) { } return null; }