-5
Я создаю сайт для управления музыкой, но я понятия не имел, как скачать mp3 с моего сервлета.Скачать mp3-файл с сервера Tomcat с помощью сервлета Java
Вот мой код:
filename=new File(imagepath).getName();
FileOutputStream fil=new FileOutputStream(pathfolder+"/"+filename);
URL url=new URL("http://192.168.1.4:8080/Demo/upload/"+filename);
HttpURLConnection urlconnection=null;
urlconnection=(HttpURLConnection)url.openConnection();
urlconnection.setRequestMethod("GET");
urlconnection.setDoOutput(true);
urlconnection.connect();
int total_size=urlconnection.getContentLength();
Log.i("totall sizeeeeeee",""+total_size);
InputStream inpstream = urlconnection.getInputStream();
byte[] buffer=new byte[total_size];
int buffleng=0,download_size=0;
while((buffleng=inpstream.read(buffer))>0)
{
fil.write(buffer,0,buffleng);
}
}
catch(Exception ex){
ex.printStackTrace();
}
Humm ... как прокси-сервер для загрузки музыки? –