Ну конечно, ты же побайтово читаешь, это во первых. А во вторых зачем ты возвращаешь строку? Сразу пиши полученные данные в файл.
| Код | public void downloadUrl(String Url, OutputStream out) throws Exception { URL url = new URL(Url); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn .setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; FunWebProducts; .NET CLR 1.1.4322)"); conn.setRequestMethod("GET"); int len = conn.getContentLength(); if(len > 0) { InputStream input = conn.getInputStream(); int read; byte[] buffer = new byte[16 * 1024]; while((read = input.read(buffer)) != -1) out.write(buffer, 0, read); input.close(); out.flush(); } else { //System.out.println("Net sodergimogo ili no connection"); } } |
где в качестве OutputStream передавай FileOutputStream куда надо записать данные. |