List of usage examples for java.io OutputStream close
public void close() throws IOException
From source file:NovoClass.java
public static void main(String[] args) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(10.1, "Maximo", "Hora 1"); dataset.addValue(20.1, "Maximo", "Hora 2"); dataset.addValue(30.1, "Maximo", "Hora 3"); dataset.addValue(40.1, "Maximo", "Hora 4"); dataset.addValue(70.1, "Maximo", "Hora 5"); JFreeChart chart = ChartFactory.createLineChart("Grafico Simpes", "Hora", "Valor", dataset, PlotOrientation.HORIZONTAL, true, true, false); try {//from ww w . ja va 2s . c o m System.out.println("Criando..."); OutputStream png = new FileOutputStream("GraficoSimples.png"); ChartUtilities.writeChartAsPNG(png, chart, 500, 400); png.close(); } catch (Exception e) { } }
From source file:SVGDOC2JPEG.java
public static void main(String[] args) throws Exception { JPEGTranscoder transcoder = new JPEGTranscoder(); transcoder.addTranscodingHint(JPEGTranscoder.KEY_XML_PARSER_CLASSNAME, "org.apache.crimson.parser.XMLReaderImpl"); transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(1.0)); TranscoderInput input = new TranscoderInput(new FileInputStream("rectangles.svg")); OutputStream ostream = new FileOutputStream("out.jpg"); TranscoderOutput output = new TranscoderOutput(ostream); transcoder.transcode(input, output); ostream.close(); System.exit(0);//from ww w .j a va 2 s .co m }
From source file:Diagramas.PieChart_AWT.java
public static void main(String[] args) throws IOException { PieChart_AWT demo = new PieChart_AWT("Mobile Sales"); demo.setSize(560, 367);//from w w w . jav a2 s . c om RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); JFreeChart chart = createChart(createDataset()); OutputStream output = new FileOutputStream("img.png"); ChartUtilities.writeChartAsPNG(output, chart, 500, 600); output.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String inFilename = "infile.zip"; ZipInputStream in = new ZipInputStream(new FileInputStream(inFilename)); ZipEntry entry = in.getNextEntry(); String outFilename = "o"; OutputStream out = new FileOutputStream(outFilename); byte[] buf = new byte[1024]; int len;/*from ww w . ja v a 2 s .c om*/ while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } out.close(); in.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { ZipInputStream in = new ZipInputStream(new FileInputStream("source.zip")); OutputStream out = new FileOutputStream("target"); byte[] buf = new byte[1024]; int len;//from w ww.j a va 2 s . c o m while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } out.close(); in.close(); }
From source file:com.web.server.ShutDownServer.java
/** * @param args// www . jav a2s.com * @throws SAXException * @throws IOException */ public static void main(String[] args) throws IOException, SAXException { DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/serverconfig-rules.xml"))); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); Digester serverdigester = serverdigesterLoader.newDigester(); ServerConfig serverconfig = (ServerConfig) serverdigester .parse(new InputSource(new FileInputStream("./config/serverconfig.xml"))); try { Socket socket = new Socket("localhost", Integer.parseInt(serverconfig.getShutdownport())); OutputStream outputStream = socket.getOutputStream(); outputStream.write("shutdown WebServer\r\n\r\n".getBytes()); outputStream.close(); } catch (IOException e1) { e1.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) throws Exception { OutputStream out = null; JarFile f = new JarFile(args[0]); Pack200.Packer packer = Pack200.newPacker(); out = new FileOutputStream(args[0] + ".pack"); packer.pack(f, out);//from w w w.ja va 2s. co m out.close(); }
From source file:FileInputOutputExample.java
public static void main(String[] args) throws Exception { InputStream is = new FileInputStream("in.txt"); OutputStream os = new FileOutputStream("out.txt"); int c;/*from w w w .j a v a2 s .c om*/ while ((c = is.read()) != -1) { System.out.print((char) c); os.write(c); } is.close(); os.close(); }
From source file:com.app.server.ShutDownServer.java
/** * @param args/* ww w . j a v a2 s . c om*/ * @throws SAXException * @throws IOException */ public static void main(String[] args) throws IOException, SAXException { DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/serverconfig-rules.xml"))); } catch (FileNotFoundException e) { log.error("Could not load rules xml serverconfig-rules.xml", e); // TODO Auto-generated catch block //e.printStackTrace(); } } }); Digester serverdigester = serverdigesterLoader.newDigester(); ServerConfig serverconfig = (ServerConfig) serverdigester .parse(new InputSource(new FileInputStream("./config/serverconfig.xml"))); try { Socket socket = new Socket("localhost", Integer.parseInt(serverconfig.getShutdownport())); OutputStream outputStream = socket.getOutputStream(); outputStream.write("shutdown WebServer\r\n\r\n".getBytes()); outputStream.close(); } catch (Exception ex) { log.error("Could not able to create socket and write shutdown bytes", ex); //e1.printStackTrace(); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { String source = "s.gzip"; GZIPInputStream in = new GZIPInputStream(new FileInputStream(source)); String target = "outfile"; OutputStream out = new FileOutputStream(target); byte[] buf = new byte[1024]; int len;//from w w w. j a va2 s . c om while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); }