byte[] buffer = new byte[4096]; int count, l = 0; do { count = is.read(buffer); if (count > 0) os.write(buffer, 0, count); l += count; } while (l < len); os.close();
if(len!=0){ byte[] buffer = new byte[4096]; int count, l = 0; do { count = is.read(buffer); if (count > 0) os.write(buffer, 0, count); l += count; } while (l < len); os.close(); }
    private File saveRequestContent(HttpServletRequest request) throws IOException {        ServletInputStream is = request.getInputStream();        int len = request.getContentLength();        // put may send a lot of data, so save it        // to a temporary file first.        File tempFile = File.createTempFile("existSRC", ".tmp");        OutputStream os = new FileOutputStream(tempFile);        byte[] buffer = new byte[4096];        int count, l = 0;        do {            count = is.read(buffer);            if (count > 0)                os.write(buffer, 0, count);            l += count;        } while (l < len);        os.close();        return tempFile;    }