0
發送PDF文件我想服務器中的PDF文件,而不是MP3文件,請幫助HttpRequestHandler:響應
private HttpRequestHandler mRequestHandler = new HttpRequestHandler()
{
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context)
throws HttpException, IOException
{
try{
File file = new File("/mnt/sdcard/Music/song.mp3");
FileEntity body = new FileEntity(file, "audio/mpeg");
response.setHeader("Content-Type", "application/force-download");
response.setHeader("Content-Disposition","attachment; filename=song.mp3");
response.setEntity(body);
}catch(Exception e)
{
e.printStackTrace();
}
}
};
我已經做了,但沒有下載pdf文件 –
它打印異常?它說什麼? – Aschab
沒有任何例外! –