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.getInstance(document, new FileOutputStream("2.pdf")); document.open();/*from www.java 2 s .c o m*/ Image img = Image.getInstance("dog.jpg"); PdfPTable table = new PdfPTable(1); table.addCell(img); document.add(table); document.close(); }
From source file:EncryptorExamplePDF.java
public static void main(String[] args) { try {// ww w . j a va 2 s. c om PdfReader reader = new PdfReader("YourOwnPDF.pdf"); PdfEncryptor.encrypt(reader, new FileOutputStream("EncryptorExamplePDF.pdf"), "Hello".getBytes(), "World".getBytes(), PdfWriter.AllowPrinting | PdfWriter.AllowCopy, false); } catch (Exception e) { e.printStackTrace(); } }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();// w w w.j a v a 2s .c o m Image tiff = Image.getInstance("dog.tiff"); document.add(tiff); tiff.scalePercent(72f / tiff.getDpiX() * 100); document.add(new Paragraph("Show the image with 360 Dpi (scaled " + (7200f / tiff.getDpiX()) + "%):")); document.add( new Paragraph("Scaled width: " + tiff.scaledWidth() + "; scaled height: " + tiff.scaledHeight())); document.add(tiff); document.close(); }
From source file:FontStyle2PDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w ww.java 2s . c om PdfWriter.getInstance(document, new FileOutputStream("FontStyle2PDF.pdf")); document.open(); Phrase myPhrase = new Phrase("new Font(Font.TIMES_ROMAN, 8, Font.BOLD)", new Font(Font.TIMES_ROMAN, 8, Font.BOLD)); document.add(myPhrase); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { MyClass o = new MyClass(123); XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("outfilename.xml"))); String[] propertyNames = new String[] { "prop" }; encoder.setPersistenceDelegate(MyClass.class, new DefaultPersistenceDelegate(propertyNames)); encoder.writeObject(o);/* w w w . j a v a 2 s . com*/ encoder.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileInputStream inStream = new FileInputStream("test.txt"); ZipOutputStream outStream = new ZipOutputStream(new FileOutputStream("compressed.zip")); outStream.putNextEntry(new ZipEntry("test.txt")); byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = inStream.read(buffer)) > 0) { outStream.write(buffer, 0, bytesRead); }//ww w .j av a 2 s . co m outStream.closeEntry(); outStream.close(); inStream.close(); }
From source file:Main.java
public static void main(String args[]) throws Exception { Properties p = new Properties(); p.put("today", new Date().toString()); p.put("user", "A"); FileOutputStream out = new FileOutputStream("user.props"); p.storeToXML(out, "updated"); FileInputStream in = new FileInputStream("user.props"); p.loadFromXML(in);/*from w w w . jav a 2 s. c o m*/ p.list(System.out); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();//from ww w.j ava2s .co m Chunk bold = new Chunk("This looks like Font.BOLD"); bold.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, 0.5f, null); document.add(bold); document.close(); }
From source file:Main.java
public static void main(String[] args) throws IOException { byte[] b = { -123, 4 }; FileOutputStream fos = new FileOutputStream("c:\\test.txt"); DataOutputStream dos = new DataOutputStream(fos); for (byte j : b) { dos.writeByte(j);//from w ww . j a va 2 s . co m } dos.flush(); InputStream is = new FileInputStream("c:\\test.txt"); DataInputStream dis = new DataInputStream(is); while (dis.available() > 0) { int k = dis.readUnsignedByte(); System.out.print(k); } }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();/* ww w . j a v a 2s . c o m*/ Phrase p = new Phrase("this is a test. "); Image img1 = Image.getInstance("foxdog.jpg"); img1.setAlignment(Image.RIGHT | Image.TEXTWRAP); document.add(img1); for (int i = 0; i < 20; i++) document.add(p); Image img2 = Image.getInstance("foxdog.gif"); img2.setAlignment(Image.MIDDLE | Image.UNDERLYING); document.add(img2); for (int i = 0; i < 30; i++) document.add(p); document.close(); }