java - HttpClient + FileUpload how to download file from servlet to my app? -


I have seen upload snippets that use HTTP clients and file uploads. But I did not find any snippet that demits the HTTP client + file upload: (If you share links or even some demo projects, please

appreciate useful comments):

Andrew

In the web context, you can use one. The resource path information here has passed as additional path information on HTTP.

  Last ServletOutputStream Out = res.getOutputStream (); Res.setContentType ("application / octet stream"); String file = req.getPathInfo (); If (file == faucet) {out.println ("Additional path information was zero; must be a resource to see"); Return; } // Convert a URL url = getServletContext (). GetResource (file); If (url == blank) {out.println ("resource" + file + "not found"); Return; } // File InputStream = url.openStream (); Byte [] buf = new byte [4 * 1024]; // 4K buffer by bit read; While ((bytes read = in. Raid (buff))! = -1) {out.written (buff, 0, bytes read); }    

Comments