List of usage examples for java.nio.file Files copy
public static long copy(InputStream in, Path target, CopyOption... options) throws IOException
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param strFichier/*from ww w . j a v a 2s .co m*/ * @param strRepertoire * @throws FileNotFoundException Exception fichier non trouv * @throws IOException Exception d'entre sortie */ static public void copieFichierRepertoire(String strFichier, String strRepertoire) throws FileNotFoundException, IOException { File fileFrom = new File(strFichier); File fileTo = new File( strRepertoire + File.separator + strFichier.substring(strFichier.lastIndexOf(File.separator) + 1)); Files.copy(fileFrom.toPath(), fileTo.toPath(), StandardCopyOption.REPLACE_EXISTING); }
From source file:rems.Global.java
public static void exprtToHTMLSCC(ResultSet dtst, String fileNm, String rptTitle, String[] colsToGrp, String[] colsToUse, boolean isfirst, boolean islast, boolean shdAppnd) { try {/*from w ww . j av a2s. c o m*/ //Simple Column Chart dtst.last(); int totlRows = dtst.getRow(); dtst.beforeFirst(); ResultSetMetaData dtstmd = dtst.getMetaData(); int colCnt = dtstmd.getColumnCount(); String cption = ""; if (isfirst) { cption = "<caption align=\"top\">" + rptTitle + "</caption>"; Global.strSB.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" " + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"[]><html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" lang=\"en-US\" xml:lang=\"en\"><head><meta http-equiv=\"Content-Type\" " + "content=\"text/html; charset=utf-8\">" + System.getProperty("line.separator") + "<title>" + rptTitle + "</title>" + System.getProperty("line.separator")); Global.strSB.append("<link rel=\"stylesheet\" href=\"../amcharts/rpt.css\" type=\"text/css\">" + System.getProperty("line.separator")); Global.strSB.append("<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">" + System.getProperty("line.separator")); Global.strSB.append("<script src=\"../amcharts/amcharts.js\" type=\"text/javascript\"></script>" + System.getProperty("line.separator")); Global.strSB.append("</head><body>"); Files.copy( new File(Global.getOrgImgsDrctry() + "/" + String.valueOf(Global.UsrsOrg_ID) + ".png") .toPath(), new File(Global.getRptDrctry() + "/amcharts_2100/images/" + String.valueOf(Global.UsrsOrg_ID) + ".png").toPath(), StandardCopyOption.REPLACE_EXISTING); if (Global.callngAppType.equals("DESKTOP")) { Global.upldImgsFTP(9, Global.getRptDrctry(), "/amcharts_2100/images/" + String.valueOf(Global.UsrsOrg_ID) + ".png"); } //Org Name String orgNm = Global.getOrgName(Global.UsrsOrg_ID); String pstl = Global.getOrgPstlAddrs(Global.UsrsOrg_ID); //Contacts Nos String cntcts = Global.getOrgContactNos(Global.UsrsOrg_ID); //Email Address String email = Global.getOrgEmailAddrs(Global.UsrsOrg_ID); Global.strSB.append("<p><img src=\"../images/" + String.valueOf(Global.UsrsOrg_ID) + ".png\">" + orgNm + "<br/>" + pstl + "<br/>" + cntcts + "<br/>" + email + "<br/>" + "</p>"); } Global.strSB.append("<script type = \"text / javascript\"> " + System.getProperty("line.separator") + "var chart;" + System.getProperty("line.separator") + "var chartData = ["); for (int a = 0; a < totlRows; a++) { dtst.next(); if (a < totlRows - 1) { Global.strSB.append( "{" + "ctgry:\"" + dtst.getString(Integer.parseInt(colsToUse[0]) + 1) + "\"," + "vals:" + dtst.getString(Integer.parseInt(colsToUse[1]) + 1) + ", color: \"#0D52D1\"},") .append(System.getProperty("line.separator")); } else { Global.strSB.append( "{" + "ctgry:\"" + dtst.getString(Integer.parseInt(colsToUse[0]) + 1) + "\"," + "vals:" + dtst.getString(Integer.parseInt(colsToUse[1]) + 1) + ", color:\"#0D52D1\"}];") .append(System.getProperty("line.separator")); } } Global.strSB.append("AmCharts.ready(function () {" + System.getProperty("line.separator") + "// SERIAL CHART " + System.getProperty("line.separator") + "chart = new AmCharts.AmSerialChart(); " + System.getProperty("line.separator") + "chart.dataProvider = chartData; " + System.getProperty("line.separator") + "chart.categoryField = \"ctgry\"; " + System.getProperty("line.separator") + "chart.depth3D = 0; " + System.getProperty("line.separator") + "chart.angle = 0; " + System.getProperty("line.separator") + "//chart.startDuration = 1;" + System.getProperty("line.separator") + "// AXES " + System.getProperty("line.separator") + "// category " + System.getProperty("line.separator") + "var categoryAxis = chart.categoryAxis; " + System.getProperty("line.separator") + "categoryAxis.labelRotation = 90; " + System.getProperty("line.separator") + "categoryAxis.title = \"" + dtstmd.getColumnName(Integer.parseInt(colsToUse[0]) + 1) + "\"; " + System.getProperty("line.separator") + "categoryAxis.gridPosition = \"start\";" + System.getProperty("line.separator") + "// value" + System.getProperty("line.separator") + "// in case you don't want to change default settings of value axis," + System.getProperty("line.separator") + "// you don't need to create it, as one value axis is created automatically. " + System.getProperty("line.separator") + "var valueAxis = new AmCharts.ValueAxis(); " + System.getProperty("line.separator") + "valueAxis.title = \"" + dtstmd.getColumnName(Integer.parseInt(colsToUse[1]) + 1) + "\"; " + System.getProperty("line.separator") + "valueAxis.dashLength = 5; " + System.getProperty("line.separator") + "chart.addValueAxis(valueAxis);" + System.getProperty("line.separator") + " // GRAPH " + System.getProperty("line.separator") + "var graph = new AmCharts.AmGraph(); " + System.getProperty("line.separator") + "graph.valueField = \"vals\"; " + System.getProperty("line.separator") + "graph.colorField = \"color\"; " + System.getProperty("line.separator") + "graph.balloonText = \"[[category]]: [[value]]\"; " + System.getProperty("line.separator") + "graph.type = \"column\"; " + System.getProperty("line.separator") + "graph.lineAlpha = 0; " + System.getProperty("line.separator") + "graph.fillAlphas = 1; " + System.getProperty("line.separator") + "chart.addGraph(graph);" + System.getProperty("line.separator") + "chart.write(\"chartdiv\");" + System.getProperty("line.separator") + "});" + System.getProperty("line.separator") + " </script>" + System.getProperty("line.separator")); Global.strSB.append("<h2>" + rptTitle + "</h2>").append(System.getProperty("line.separator")); Global.strSB.append("<div id=\"chartdiv\" style=\"width: " + colsToGrp[0] + "px; height: " + colsToGrp[1] + "px;\"></div>"); if (islast) { Global.strSB.append("</body></html>"); File file = new File(fileNm); // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); BufferedWriter bw = new BufferedWriter(fw); bw.write(Global.strSB.length()); bw.close(); if (Global.callngAppType.equals("DESKTOP")) { Global.upldImgsFTP(9, Global.getRptDrctry(), "/amcharts_2100/samples/" + String.valueOf(Global.runID) + ".html"); } } } catch (SQLException ex) { } catch (IOException ex) { } catch (NumberFormatException ex) { } }
From source file:rems.Global.java
public static void exprtToHTMLPC(ResultSet dtst, String fileNm, String rptTitle, String[] colsToGrp, String[] colsToUse, boolean isfirst, boolean islast, boolean shdAppnd) { //Pie Chart// w ww .ja va 2 s. c o m //int colCnt = dtst.Tables[0].Columns.Count; //for (int p = 0; p < colsToGrp.length; p++) //{ // Global.errorLog = "colsToGrp[" + p + "] = " + colsToGrp[p]; //} //for (int p = 0; p < colsToUse.length; p++) //{ // Global.errorLog = "colsToUse[" + p + "] = " + colsToUse[p]; //} //Global.writeToLog(); try { dtst.last(); int totlRows = dtst.getRow(); dtst.beforeFirst(); ResultSetMetaData dtstmd = dtst.getMetaData(); int colCnt = dtstmd.getColumnCount(); String cption = ""; if (isfirst) { cption = "<caption align=\"top\">" + rptTitle + "</caption>"; Global.strSB.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" " + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"[]><html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" lang=\"en-US\" xml:lang=\"en\"><head><meta http-equiv=\"Content-Type\" " + "content=\"text/html; charset=utf-8\"><title>" + rptTitle + "</title>") .append(System.getProperty("line.separator")) .append("<link rel=\"stylesheet\" href=\"../amcharts/rpt.css\" type=\"text/css\">") .append(System.getProperty("line.separator")); Global.strSB.append("<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">") .append(System.getProperty("line.separator")) .append("<script src = \"../amcharts / amcharts.js\" type = \"text / javascript\"></script > ") .append(System.getProperty("line.separator")); Global.strSB.append("</head><body>").append(System.getProperty("line.separator")); Files.copy( new File(Global.getOrgImgsDrctry() + "/" + String.valueOf(Global.UsrsOrg_ID) + ".png") .toPath(), new File(Global.getRptDrctry() + "/amcharts_2100/images/" + String.valueOf(Global.UsrsOrg_ID) + ".png").toPath(), StandardCopyOption.REPLACE_EXISTING); if (Global.callngAppType.equals("DESKTOP")) { Global.upldImgsFTP(9, Global.getRptDrctry(), "/amcharts_2100/images/" + String.valueOf(Global.UsrsOrg_ID) + ".png"); } //Org Name String orgNm = Global.getOrgName(Global.UsrsOrg_ID); String pstl = Global.getOrgPstlAddrs(Global.UsrsOrg_ID); //Contacts Nos String cntcts = Global.getOrgContactNos(Global.UsrsOrg_ID); //Email Address String email = Global.getOrgEmailAddrs(Global.UsrsOrg_ID); Global.strSB .append("<p><img src=\"../images/" + String.valueOf(Global.UsrsOrg_ID) + ".png\">" + orgNm + "<br/>" + pstl + "<br/>" + cntcts + "<br/>" + email + "<br/>" + "</p>") .append(System.getProperty("line.separator")); } Global.strSB.append("<script type=\"text/javascript\">").append(System.getProperty("line.separator")) .append("var chart;").append(System.getProperty("line.separator")).append("var chartData = ["); for (int a = 0; a < totlRows; a++) { dtst.next(); if (a < totlRows - 1) { Global.strSB .append("{ctgry:\"" + dtst.getString(Integer.parseInt(colsToUse[0]) + 1) + "\", " + "vals:" + dtst.getString(Integer.parseInt(colsToUse[1]) + 1) + "},") .append(System.getProperty("line.separator")); } else { Global.strSB .append("{ctgry:\"" + dtst.getString(Integer.parseInt(colsToUse[0]) + 1) + "\", " + "vals:" + dtst.getString(Integer.parseInt(colsToUse[1]) + 1) + "}];") .append(System.getProperty("line.separator")); } } Global.strSB.append("AmCharts.ready(function () {").append(System.getProperty("line.separator")) .append("// PIE CHART").append(System.getProperty("line.separator")) .append("chart = new AmCharts.AmPieChart();").append(System.getProperty("line.separator")) .append("chart.dataProvider = chartData;").append(System.getProperty("line.separator")) .append("chart.titleField = \"ctgry\";").append(System.getProperty("line.separator")) .append("chart.valueField = \"vals\";").append(System.getProperty("line.separator")) .append("chart.outlineColor = \"#FFFFFF\";").append(System.getProperty("line.separator")) .append("chart.outlineAlpha = 0.8;").append(System.getProperty("line.separator")) .append("chart.outlineThickness = 2;").append(System.getProperty("line.separator")) .append("// this makes the chart 3D").append(System.getProperty("line.separator")) .append("chart.depth3D = 15;").append(System.getProperty("line.separator")) .append("chart.angle = 30;").append(System.getProperty("line.separator")) .append("chart.write(\"chartdiv\");").append(System.getProperty("line.separator")).append("});") .append(System.getProperty("line.separator")).append("</script>") .append(System.getProperty("line.separator")); Global.strSB.append("<h2>" + rptTitle + "</h2>").append(System.getProperty("line.separator")); Global.strSB.append("<div id=\"chartdiv\" style=\"width: " + colsToGrp[0] + "px; height: " + colsToGrp[1] + "px;\"></div>").append(System.getProperty("line.separator")); if (islast) { Global.strSB.append("</body></html>"); File file = new File(fileNm); // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); BufferedWriter bw = new BufferedWriter(fw); bw.write(Global.strSB.toString()); bw.close(); if (Global.callngAppType.equals("DESKTOP")) { Global.upldImgsFTP(9, Global.getRptDrctry(), "/amcharts_2100/samples/" + String.valueOf(Global.runID) + ".html"); } } } catch (SQLException ex) { } catch (IOException ex) { } catch (NumberFormatException ex) { } }
From source file:rems.Global.java
public static void exprtToHTMLLC(ResultSet dtst, String fileNm, String rptTitle, String[] colsToGrp, String[] colsToUse, boolean isfirst, boolean islast, boolean shdAppnd) { try {//from www .j a v a 2s. c o m //Line Chart dtst.last(); int totlRows = dtst.getRow(); dtst.beforeFirst(); ResultSetMetaData dtstmd = dtst.getMetaData(); //int colCnt = dtstmd.getColumnCount(); int colCnt = colsToUse.length; String cption = ""; if (isfirst) { cption = "<caption align=\"top\">" + rptTitle + "</caption>"; Global.strSB.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" " + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"[]><html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" lang=\"en-US\" xml:lang=\"en\"><head><meta http-equiv=\"Content-Type\" " + "content=\"text/html; charset=utf-8\"><title>" + rptTitle + "</title>") .append(System.getProperty("line.separator")) .append("<link rel=\"stylesheet\" href=\"../amcharts/rpt.css\" type=\"text/css\">") .append(System.getProperty("line.separator")); Global.strSB.append("<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">") .append(System.getProperty("line.separator")) .append("<script src = \"../amcharts / amcharts.js\" type = \"text / javascript\">") .append(System.getProperty("line.separator")).append("</script>") .append(System.getProperty("line.separator")); Global.strSB.append("</head><body>").append(System.getProperty("line.separator")); Files.copy( new File(Global.getOrgImgsDrctry() + "/" + String.valueOf(Global.UsrsOrg_ID) + ".png") .toPath(), new File(Global.getRptDrctry() + "/amcharts_2100/images/" + String.valueOf(Global.UsrsOrg_ID) + ".png").toPath(), StandardCopyOption.REPLACE_EXISTING); if (Global.callngAppType.equals("DESKTOP")) { Global.upldImgsFTP(9, Global.getRptDrctry(), "/amcharts_2100/images/" + String.valueOf(Global.UsrsOrg_ID) + ".png"); } //Org Name String orgNm = Global.getOrgName(Global.UsrsOrg_ID); String pstl = Global.getOrgPstlAddrs(Global.UsrsOrg_ID); //Contacts Nos String cntcts = Global.getOrgContactNos(Global.UsrsOrg_ID); //Email Address String email = Global.getOrgEmailAddrs(Global.UsrsOrg_ID); Global.strSB .append("<p><img src=\"../images/" + String.valueOf(Global.UsrsOrg_ID) + ".png\">" + orgNm + "<br/>" + pstl + "<br/>" + cntcts + "<br/>" + email + "<br/>" + "</p>") .append(System.getProperty("line.separator")); } Global.strSB.append("<script type=\"text/javascript\">").append(System.getProperty("line.separator")) .append("var chart;").append(System.getProperty("line.separator")).append("var chartData = [") .append(System.getProperty("line.separator")); for (int a = 0; a < totlRows; a++) { dtst.next(); if (a < totlRows - 1) { Global.strSB .append("{" + "ctgry:\"" + dtst.getString(Integer.parseInt(colsToUse[0]) + 1) + "\", " + "value: " + dtst.getString(Integer.parseInt(colsToUse[1]) + 1) + "},") .append(System.getProperty("line.separator")); } else { Global.strSB .append("{" + "ctgry:\"" + dtst.getString(Integer.parseInt(colsToUse[0]) + 1) + "\", " + "value:" + dtst.getString(Integer.parseInt(colsToUse[1]) + 1) + "}];") .append(System.getProperty("line.separator")); } } Global.strSB.append("AmCharts.ready(function () {").append(System.getProperty("line.separator")) .append("// SERIAL CHART").append(System.getProperty("line.separator")) .append("chart = new AmCharts.AmSerialChart();").append(System.getProperty("line.separator")) .append("chart.pathToImages = \"../amcharts/images/\";") .append(System.getProperty("line.separator")).append("chart.dataProvider = chartData;") .append(System.getProperty("line.separator")).append("chart.marginLeft = 10;") .append(System.getProperty("line.separator")).append("chart.categoryField = \"ctgry\";") .append(System.getProperty("line.separator")).append("chart.zoomOutButton = {") .append(System.getProperty("line.separator")).append("backgroundColor: '#000000',") .append("backgroundAlpha: 0.15};").append(System.getProperty("line.separator")) .append("// listen for dataUpdated event (fired when chart is inited) and call zoomChart method when it happens") .append(System.getProperty("line.separator")) .append("chart.addListener(\"dataUpdated\", zoomChart);") .append(System.getProperty("line.separator")).append("// AXES") .append(System.getProperty("line.separator")).append("// category") .append(System.getProperty("line.separator")).append("var categoryAxis = chart.categoryAxis;") .append(System.getProperty("line.separator")) .append("//categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true") .append(System.getProperty("line.separator")) .append("//categoryAxis.minPeriod = DD; // our data is ctgryly, so we set minPeriod to YYYY") .append(System.getProperty("line.separator")) .append("categoryAxis.title = \"" + dtstmd.getColumnName(Integer.parseInt(colsToUse[0]) + 1) + "\";") .append(System.getProperty("line.separator")).append("categoryAxis.gridAlpha = 0.5;") .append(System.getProperty("line.separator")).append("categoryAxis.labelRotation = 90;") .append(System.getProperty("line.separator")).append("// value") .append(System.getProperty("line.separator")) .append("var valueAxis = new AmCharts.ValueAxis();") .append(System.getProperty("line.separator")).append("valueAxis.axisAlpha = 0.5;") .append(System.getProperty("line.separator")) .append("valueAxis.title = \"" + dtstmd.getColumnName(Integer.parseInt(colsToUse[1]) + 1) + "\";") .append(System.getProperty("line.separator")).append("valueAxis.inside = true;") .append(System.getProperty("line.separator")).append("chart.addValueAxis(valueAxis);") .append(System.getProperty("line.separator")).append("// GRAPH ") .append(System.getProperty("line.separator")).append("graph = new AmCharts.AmGraph();") .append(System.getProperty("line.separator")) .append("graph.type = \"line\"; // this line makes the graph smoothed line.") .append(System.getProperty("line.separator")).append("graph.lineColor = \"#0000FF\";") .append(System.getProperty("line.separator")) .append("graph.negativeLineColor = \"#637bb6\"; // this line makes the graph to change color when it drops below 0") .append(System.getProperty("line.separator")).append("graph.bullet = \"round\";") .append(System.getProperty("line.separator")).append("graph.bulletSize = 5;") .append("graph.lineThickness = 1;").append(System.getProperty("line.separator")) .append("graph.valueField = \"value\";").append(System.getProperty("line.separator")) .append("chart.addGraph(graph);").append(System.getProperty("line.separator")) .append("// CURSOR ").append(System.getProperty("line.separator")) .append("var chartCursor = new AmCharts.ChartCursor();") .append(System.getProperty("line.separator")).append("chartCursor.cursorAlpha = 0;") .append(System.getProperty("line.separator")).append("chartCursor.cursorPosition = \"mouse\";") .append(System.getProperty("line.separator")) .append("//chartCursor.categoryBalloonDateFormat = \"YYYY\";") .append(System.getProperty("line.separator")).append("chart.addChartCursor(chartCursor);") .append(System.getProperty("line.separator")).append("// SCROLLBAR ") .append(System.getProperty("line.separator")) .append("var chartScrollbar = new AmCharts.ChartScrollbar();") .append(System.getProperty("line.separator")).append("chartScrollbar.graph = graph;") .append(System.getProperty("line.separator")) .append("chartScrollbar.backgroundColor = \"#DDDDDD\";") .append(System.getProperty("line.separator")).append("chartScrollbar.scrollbarHeight = 15;") .append(System.getProperty("line.separator")) .append("chartScrollbar.selectedBackgroundColor = \"#FFFFFF\";") .append(System.getProperty("line.separator")).append("chart.addChartScrollbar(chartScrollbar);") .append(System.getProperty("line.separator")).append("// WRITE") .append(System.getProperty("line.separator")).append("chart.write(\"chartdiv\");") .append(System.getProperty("line.separator")).append("});") .append(System.getProperty("line.separator")) .append("// this method is called when chart is first inited as we listen for \"dataUpdated\" event") .append(System.getProperty("line.separator")).append("function zoomChart() {") .append(System.getProperty("line.separator")) .append("// different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues") .append(System.getProperty("line.separator")) .append("//chart.zoomToDates(new Date(1972, 0), new Date(1984, 0));") .append(System.getProperty("line.separator")).append("chart.zoomToIndexes(0,100);") .append(System.getProperty("line.separator")).append("}") .append(System.getProperty("line.separator")).append("</script>") .append(System.getProperty("line.separator")); Global.strSB.append("<h2>" + rptTitle + "</h2>").append(System.getProperty("line.separator")); Global.strSB.append("<div id=\"chartdiv\" style=\"width: " + colsToGrp[0] + "px; height: " + colsToGrp[1] + "px;\"></div>").append(System.getProperty("line.separator")); if (islast) { Global.strSB.append("</body></html>"); File file = new File(fileNm); // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); BufferedWriter bw = new BufferedWriter(fw); bw.write(Global.strSB.toString()); bw.close(); if (Global.callngAppType.equals("DESKTOP")) { Global.upldImgsFTP(9, Global.getRptDrctry(), "/amcharts_2100/samples/" + String.valueOf(Global.runID) + ".html"); } } } catch (SQLException ex) { } catch (IOException ex) { } catch (NumberFormatException ex) { } }