List of usage examples for java.io IOException toString
public String toString()
From source file:ObjectWriter.java
public static void main(String[] arguments) { Message mess = new Message(); String author = "London"; String recipient = "G, B"; String[] letter = { "Merry Christmas." }; Date now = new Date(); mess.writeMessage(author, recipient, now, letter); try {// w ww.j a va 2s .com FileOutputStream fo = new FileOutputStream("Message.obj"); ObjectOutputStream oo = new ObjectOutputStream(fo); oo.writeObject(mess); oo.close(); System.out.println("Object created successfully."); } catch (IOException e) { System.out.println("Error - " + e.toString()); } }
From source file:org.jfree.chart.demo.MeterChartDemo2.java
/** * Starting point for the demo./*w w w . j a v a 2s . c om*/ * * @param args ignored. */ public static void main(final String[] args) { final ValueDataset dataset = new DefaultValueDataset(75.0); final MeterPlot plot = new MeterPlot(dataset); final JFreeChart chart = new JFreeChart("Scaled Image Test", plot); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final File file1 = new File("meterchart100.png"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file1)); final BufferedImage image = chart.createBufferedImage(200, 200, 400, 400, null); ChartUtilities.writeBufferedImageAsPNG(out, image); } catch (IOException e) { System.out.println(e.toString()); } }
From source file:org.jfree.chart.demo.ImageMapDemo7.java
/** * Starting point for the demo.//from w w w .j av a 2 s. c o m * * @param args ignored. */ public static void main(final String[] args) { final XYDataset data = new SampleXYDataset2(); final JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); // final Legend legend = chart.getLegend(); // if (legend instanceof StandardLegend) { // final StandardLegend sl = (StandardLegend) legend; // sl.setDisplaySeriesShapes(true); //} final NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("scatter100.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("scatter100.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"scatter100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } }
From source file:com.leonarduk.finance.chart.PieChartFactory.java
/** * Starting point for the demo.//w ww. j av a 2s . c o m * * @param args * ignored. */ public static void main(final String[] args) { final PieChartFactory factory = new PieChartFactory("Title"); factory.put("A", 12.2).put("B", 13.2).put("C", 31.2); try { // write an HTML page incorporating the image with an image map final File file2 = new File("multipiechart100.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println(ChartDisplay.saveImageAsPngAndReturnHtmlLink("345", 400, 400, factory.buildChart())); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (final IOException e) { System.out.println(e.toString()); } }
From source file:com.rdio.simple.examples.CommandLine.java
public static void main(String[] args) throws IOException, JSONException { ConsumerCredentials consumerCredentials = new ConsumerCredentials(); RdioClient rdio = new RdioCoreClient(consumerCredentials); try {//from w w w . j av a 2 s . c o m RdioClient.AuthState authState = rdio.beginAuthentication("oob"); System.out.println("Go to: " + authState.url); System.out.print("Then enter the code: "); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String verifier = reader.readLine().trim(); RdioClient.Token accessToken = rdio.completeAuthentication(verifier, authState.requestToken); rdio = new RdioCoreClient(consumerCredentials, accessToken); try { JSONObject response = new JSONObject(rdio.call("getPlaylists")); JSONArray playlists = (JSONArray) ((JSONObject) response.get("result")).get("owned"); for (int i = 0; i < playlists.length(); i++) { JSONObject playlist = playlists.getJSONObject(i); System.out.println(playlist.getString("shortUrl") + "\t" + playlist.getString("name")); } } catch (IOException e) { e.printStackTrace(); } } catch (RdioClient.RdioException e) { System.err.println("Rdio Error: " + e.toString()); } }
From source file:org.jfree.chart.demo.ImageMapDemo2.java
/** * The starting point for the demo.// w w w . java 2 s . c o m * * @param args ignored. */ public static void main(final String[] args) { // create a chart final DefaultPieDataset data = new DefaultPieDataset(); data.setValue("One", new Double(43.2)); data.setValue("Two", new Double(10.0)); data.setValue("Three", new Double(27.5)); data.setValue("Four", new Double(17.5)); data.setValue("Five", new Double(11.0)); data.setValue("Six", new Double(19.4)); JFreeChart chart = null; final boolean drilldown = true; // create the chart... if (drilldown) { final PiePlot plot = new PiePlot(data); // plot.setInsets(new Insets(0, 5, 5, 5)); plot.setToolTipGenerator(new StandardPieItemLabelGenerator()); plot.setURLGenerator(new StandardPieURLGenerator("pie_chart_detail.jsp")); chart = new JFreeChart("Pie Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } else { chart = ChartFactory.createPieChart("Pie Chart Demo 1", // chart title data, // data true, // include legend true, false); } chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("piechart100.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("piechart100.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo 2</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"piechart100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } }
From source file:org.jfree.chart.demo.ImageMapDemo4.java
/** * Starting point for the demo.//from w w w . ja va 2 s . c o m * * @param args ignored. */ public static void main(final String[] args) { // create a chart final double[][] data = new double[][] { { 56.0, -12.0, 34.0, 76.0, 56.0, 100.0, 67.0, 45.0 }, { 37.0, 45.0, 67.0, 25.0, 34.0, 34.0, 100.0, 53.0 }, { 43.0, 54.0, 34.0, 34.0, 87.0, 64.0, 73.0, 12.0 } }; final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "Type ", data); JFreeChart chart = null; final boolean drilldown = true; if (drilldown) { final CategoryAxis3D categoryAxis = new CategoryAxis3D("Category"); final ValueAxis valueAxis = new NumberAxis3D("Value"); final BarRenderer3D renderer = new BarRenderer3D(); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setItemURLGenerator(new StandardCategoryURLGenerator("bar_chart_detail.jsp")); final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); chart = new JFreeChart("Bar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } else { chart = ChartFactory.createBarChart3D("Bar Chart", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false); } chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("barchart101.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("barchart101.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"barchart100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } }
From source file:org.jfree.chart.demo.ImageMapDemo1.java
/** * Starting point for the demo./*from w w w .j a v a2s. c o m*/ * * @param args ignored. */ public static void main(final String[] args) { // create a chart final double[][] data = new double[][] { { 56.0, -12.0, 34.0, 76.0, 56.0, 100.0, 67.0, 45.0 }, { 37.0, 45.0, 67.0, 25.0, 34.0, 34.0, 100.0, 53.0 }, { 43.0, 54.0, 34.0, 34.0, 87.0, 64.0, 73.0, 12.0 } }; final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "Type ", data); JFreeChart chart = null; final boolean drilldown = true; if (drilldown) { final CategoryAxis categoryAxis = new CategoryAxis("Category"); final ValueAxis valueAxis = new NumberAxis("Value"); final BarRenderer renderer = new BarRenderer(); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setItemURLGenerator(new StandardCategoryURLGenerator("bar_chart_detail.jsp")); final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); chart = new JFreeChart("Bar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } else { chart = ChartFactory.createBarChart("Vertical Bar Chart", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false); } chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("barchart100.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("barchart100.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"barchart100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } }
From source file:org.jfree.chart.demo.ImageMapDemo3.java
/** * Starting point for the demo.//from w w w . j av a 2s . com * * @param args ignored. * * @throws ParseException if there is a problem parsing dates. */ public static void main(final String[] args) throws ParseException { // Create a sample dataset final SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy"); final XYSeries dataSeries = new XYSeries("Curve data"); final ArrayList toolTips = new ArrayList(); dataSeries.add(sdf.parse("01-Jul-2002").getTime(), 5.22); toolTips.add("1D - 5.22"); dataSeries.add(sdf.parse("02-Jul-2002").getTime(), 5.18); toolTips.add("2D - 5.18"); dataSeries.add(sdf.parse("03-Jul-2002").getTime(), 5.23); toolTips.add("3D - 5.23"); dataSeries.add(sdf.parse("04-Jul-2002").getTime(), 5.15); toolTips.add("4D - 5.15"); dataSeries.add(sdf.parse("05-Jul-2002").getTime(), 5.22); toolTips.add("5D - 5.22"); dataSeries.add(sdf.parse("06-Jul-2002").getTime(), 5.25); toolTips.add("6D - 5.25"); dataSeries.add(sdf.parse("07-Jul-2002").getTime(), 5.31); toolTips.add("7D - 5.31"); dataSeries.add(sdf.parse("08-Jul-2002").getTime(), 5.36); toolTips.add("8D - 5.36"); final XYSeriesCollection xyDataset = new XYSeriesCollection(dataSeries); final CustomXYToolTipGenerator ttg = new CustomXYToolTipGenerator(); ttg.addToolTipSeries(toolTips); // Create the chart final StandardXYURLGenerator urlg = new StandardXYURLGenerator("xy_details.jsp"); final ValueAxis timeAxis = new DateAxis(""); final NumberAxis valueAxis = new NumberAxis(""); valueAxis.setAutoRangeIncludesZero(false); // override default final XYPlot plot = new XYPlot(xyDataset, timeAxis, valueAxis, null); final StandardXYItemRenderer sxyir = new StandardXYItemRenderer( StandardXYItemRenderer.LINES + StandardXYItemRenderer.SHAPES, ttg, urlg); sxyir.setShapesFilled(true); plot.setRenderer(sxyir); final JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("xychart100.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("xychart100.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"xychart100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } return; }
From source file:com.nubits.nubot.launch.NuPriceMonitor.java
public static void main(String[] args) { mainThread = Thread.currentThread(); //Load settings Utils.loadProperties("settings.properties"); String folderName = "NuPriceMonitor_" + System.currentTimeMillis() + "/"; String logsFolder = Global.settings.getProperty("log_path") + folderName; //Create log dir FileSystem.mkdir(logsFolder); try {/*from w w w. ja va2 s . c o m*/ NuLogger.setup(false, logsFolder); } catch (IOException ex) { LOG.severe(ex.toString()); } NuPriceMonitor app = new NuPriceMonitor(); if (app.readParams(args)) { createShutDownHook(); app.init(); LOG.fine("Launching NuCheckPrice "); app.exec(); } else { System.exit(0); } }