public String Export(String cpt, String reportName,String fileType, String param, String filePath) { String fileName = ""; try { String serverIP = ConfigurationUtil.getUserConfigSingleValue("finereport-server", "server", "serverIP"); String port = ConfigurationUtil.getUserConfigSingleValue("finereport-server", "server", "port"); String appurl = "http://"+serverIP+":"+port+"/"; String exurl =""; if("PNG".equalsIgnoreCase(fileType) || "JPG".equalsIgnoreCase(fileType)) { exurl = appurl + "FineReport/decisioniew/report?viewlet="+cpt+"&format=image"; }else if("EXCEL".equalsIgnoreCase(fileType)){ exurl = appurl + "FineReport/decisioniew/report?viewlet="+cpt+"&format=excel"; }else if("PDF".equalsIgnoreCase(fileType)){ exurl = appurl + "FineReport/decisioniew/report?viewlet="+cpt+"&format=pdf"; } if(param!=null && !"".equals(param)){ exurl =exurl+param; } //取帆软安全认证Token String response = Jlogin.getData(""); response = response.replace("callback(", ""); response = response.replace(")", ""); JSONObject root = new JSONObject(response); String jsonObject =root.getString("accessToken"); System.out.println("token="+jsonObject); PrintlnLog.println(exurl); exurl = exurl+"&fine_auth_token="+jsonObject; System.out.println("*********************************************************************************************************"); System.out.println("exurl=========================="+exurl); System.out.println("*********************************************************************************************************"); URL url = new URL(exurl); URLConnection connection = url.openConnection(); BufferedInputStream bis = new BufferedInputStream(connection.getInputStream()); fileName = reportName + ExportApi.SEND_FILETYPE.get(fileType); FileOutputStream outputStream = new FileOutputStream(new File(fileName)); byte[] buff = new byte[1024]; int byteRead; while (-1!=(byteRead=bis.read(buff,0,buff.length))){ outputStream.write(buff,0,byteRead); } //关闭流对象 outputStream.close(); }catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } catch (Exception e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } return fileName; }