List of usage examples for java.io FileOutputStream FileOutputStream
public FileOutputStream(FileDescriptor fdObj)
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();/*from ww w. j a va 2s . c om*/ PdfContentByte over = writer.getDirectContent(); PdfContentByte under = writer.getDirectContentUnder(); drawLayer(over, 70, 750, 150, 100); drawLayer(under, 70, 730, 150, 100); document.close(); }
From source file:NewPageChunkNEXTPAGEPDF.java
public static void main(String[] args) { Document document = new Document(); try {//ww w . j a v a 2 s . c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("NewPageChunkNEXTPAGEPDF.pdf")); document.open(); document.add(new Paragraph("A")); document.newPage(); document.add(new Paragraph("B")); document.newPage(); document.add(Chunk.NEXTPAGE); document.add(new Paragraph("C")); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:NewPagePageEmptyPDF.java
public static void main(String[] args) { Document document = new Document(); try {// w w w. j a v a2 s. c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("NewPagePageEmptyPDF.pdf")); document.open(); document.add(new Paragraph("A")); document.newPage(); document.add(new Paragraph("B")); document.newPage(); document.add(Chunk.NEWLINE); document.newPage(); document.newPage(); document.add(new Paragraph("C")); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
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 va2s. co m*/ while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); }
From source file:Main.java
public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException { Formatter formatter = new Formatter(new PrintStream(new FileOutputStream("generated/format.txt"))); // format a new string String name = "from java2s.com"; formatter.format("Hello %s !", name); // print the formatted string System.out.println(formatter); // flush the formatter. Here it does nothing. formatter.flush();//from w w w. j a va 2 s.co m System.out.println("Formatter Flushed."); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(new Rectangle(14400, 14400)); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); writer.setPdfVersion(PdfWriter.VERSION_1_6); writer.setUserunit(75000f);// w w w . jav a 2 s . c o m document.open(); document.add(new Paragraph("Hello World")); document.close(); }
From source file:FormFillAndMakeItFlattenPDF.java
public static void main(String[] args) { try {/*from ww w .j a v a 2 s . co m*/ PdfReader reader = new PdfReader("SimpleRegistrationForm.pdf"); PdfStamper stamp2 = new PdfStamper(reader, new FileOutputStream("FormFillAndMakeItFlattenPDF.pdf")); AcroFields form2 = stamp2.getAcroFields(); form2.setField("name", "your name"); form2.setField("address", "address"); form2.setField("postal_code", "code"); form2.setField("email", "youremail"); stamp2.setFormFlattening(true); stamp2.close(); } catch (Exception de) { de.printStackTrace(); } }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("HelloWorldMultiple.pdf")); RtfWriter2.getInstance(document, new FileOutputStream("HelloWorldMultiple.rtf")); HtmlWriter.getInstance(document, new FileOutputStream("HelloWorldMultiple.htm")); document.open();//from w w w.jav a 2 s . c o m document.add(new Paragraph("Hello World")); document.close(); }
From source file:LINECAPROUNDPDF.java
public static void main(String[] args) { Document document = new Document(); try {/* ww w. ja v a2s .c o m*/ PdfWriter.getInstance(document, new FileOutputStream("LINECAPROUNDPDF.pdf")); document.open(); Chunk chunk; chunk = new Chunk("Multiple lines"); chunk.setUnderline(new Color(0xFF, 0x00, 0x00), 0.0f, 0.3f, 0.0f, 0.4f, PdfContentByte.LINE_CAP_ROUND); document.add(chunk); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { String source = "s.txt"; String destination = "d.txt"; FileInputStream fis = new FileInputStream(source); FileOutputStream fos = new FileOutputStream(destination); FileChannel fci = fis.getChannel(); FileChannel fco = fos.getChannel(); ByteBuffer buffer = ByteBuffer.allocate(1024); while (true) { int read = fci.read(buffer); if (read == -1) break; buffer.flip();/*from w w w. j av a 2 s .c om*/ fco.write(buffer); buffer.clear(); } }