| | |
| | | public void downLoadDataBase(@RequestBody PartnerDockingInfo partnerDockingInfo, HttpServletResponse response) { |
| | | String dbSql = partnerDockingInfoService.createSQL(partnerDockingInfo); |
| | | |
| | | OutputStream out = null; |
| | | InputStream fileInputStream = null; |
| | | try { |
| | | //BASE64Decoder dencoder = new BASE64Decoder(); |
| | | byte[] arr = dbSql.getBytes(); |
| | | if ((dbSql == null) ||(dbSql.isEmpty())) { |
| | | log.error("创建私有云数据库脚本出错!"); |
| | | } else { |
| | | |
| | | // 设置输出的格式 |
| | | response.reset(); |
| | | response.setContentType("application/x-msdownload"); |
| | | response.addHeader("Content-Length", "" + arr.length); |
| | | response.addHeader("Content-Disposition", "attachment; filename=\"" + partnerDockingInfo.getHospitalName()+partnerDockingInfo.getDepartmentName() + ".sql\""); |
| | | OutputStream out = null; |
| | | InputStream fileInputStream = null; |
| | | try { |
| | | //BASE64Decoder dencoder = new BASE64Decoder(); |
| | | byte[] arr = dbSql.getBytes(); |
| | | |
| | | // 设置输出的格式 |
| | | response.reset(); |
| | | response.setContentType("application/x-msdownload"); |
| | | response.addHeader("Content-Length", "" + arr.length); |
| | | response.addHeader("Content-Disposition", "attachment; filename=\"" + partnerDockingInfo.getHospitalName() + partnerDockingInfo.getDepartmentName() + ".sql\""); |
| | | |
| | | |
| | | out = response.getOutputStream(); |
| | | fileInputStream = new ByteArrayInputStream(arr); |
| | | byte[] buffer = new byte[1024 * 10]; |
| | | int len = 0; |
| | | while ((len = fileInputStream.read(buffer)) > 0) { |
| | | out.write(buffer, 0, len); |
| | | } |
| | | |
| | | out = response.getOutputStream(); |
| | | fileInputStream = new ByteArrayInputStream(arr); |
| | | byte[] buffer = new byte[1024 * 10] ; |
| | | int len = 0; |
| | | while ((len = fileInputStream.read(buffer)) > 0) { |
| | | out.write(buffer, 0, len); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | |
| | | } finally { |
| | | |
| | | if (fileInputStream != null) { |
| | | try { |
| | | fileInputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | if (fileInputStream != null) { |
| | | try { |
| | | fileInputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |