List of usage examples for java.io FileOutputStream FileOutputStream
public FileOutputStream(FileDescriptor fdObj)
From source file:Main.java
public static void main(String[] args) throws Exception { Properties prop = new Properties(); prop.put("Chapter Count", "200"); prop.put("Tutorial Count", "15"); prop.put("tutorial", "java2s.com"); // create a output and input as a xml file FileOutputStream fos = new FileOutputStream("properties.xml"); FileInputStream fis = new FileInputStream("properties.xml"); prop.storeToXML(fos, "Properties Example", "ISO 8859"); while (fis.available() > 0) { System.out.print((char) fis.read()); }// w w w. j av a2 s . co m }
From source file:TableCellColorPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w w w .j av a2 s .c o m PdfWriter.getInstance(document, new FileOutputStream("TableCellColorPDF.pdf")); document.open(); PdfPTable table = new PdfPTable(1); PdfPCell cell = new PdfPCell(new Paragraph("cell test1")); cell.setBorderColor(new Color(255, 0, 0)); table.addCell(cell); cell = new PdfPCell(new Paragraph("cell test2")); table.addCell(cell); document.add(table); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:SpotColorsPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from www . j a v a 2 s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpotColorsPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfSpotColor spc_cmyk = new PdfSpotColor("PANTONE 280 CV", 0.25f, new CMYKColor(0.9f, .2f, .3f, .1f)); cb.setColorStroke(spc_cmyk, .5f); cb.setLineWidth(10f); cb.rectangle(100, 700, 100, 100); cb.stroke(); } catch (Exception de) { de.printStackTrace(); } document.close(); }
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. ja va2 s .c o m*/ Chunk line = new Chunk("this is a test"); line.setUnderline(0.5f, 3f); Paragraph p = new Paragraph(); p.add(line); document.add(p); document.add(Chunk.NEWLINE); document.close(); }
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.co m Chunk line = new Chunk("this is a test"); line.setUnderline(0.2f, 14f); Paragraph p = new Paragraph(); p.add(line); document.add(p); document.add(Chunk.NEWLINE); document.close(); }
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 ava 2s . c om Chunk foxLineUnder = new Chunk("this is a test"); foxLineUnder.setUnderline(0.2f, -2f); Paragraph p = new Paragraph(); p.add(foxLineUnder); document.add(p); document.add(Chunk.NEWLINE); document.close(); }
From source file:MainClass.java
public static void main(String[] a) throws Exception { String elements[] = { "A", "B", "C", "D", "E" }; Set set = new HashSet(Arrays.asList(elements)); FileOutputStream fos = new FileOutputStream("set.ser"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(set);//from ww w. ja va 2s . co m oos.close(); FileInputStream fis = new FileInputStream("set.ser"); ObjectInputStream ois = new ObjectInputStream(fis); Set anotherSet = (Set) ois.readObject(); ois.close(); System.out.println(anotherSet); }
From source file:ChangingDocumentMarginPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A5, 36, 72, 108, 180); try {//from ww w .ja v a 2 s .c o m PdfWriter.getInstance(document, new FileOutputStream("ChangingDocumentMarginPDF.pdf")); document.open(); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_JUSTIFIED); for (int i = 0; i < 60; i++) { paragraph.add("www.java2s.com has demo for Java, JavaScript, PDF."); } document.add(paragraph); document.setMargins(180, 108, 72, 36); document.add(new Paragraph("Now we change the margins. You will see the effect on the next page.")); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:AddingAWTImageColorPDF.java
public static void main(String[] args) { Document document = new Document(); try {/* w ww . j a v a 2 s . co m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("AddingAWTImageColorPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); java.awt.Image awtImage = Toolkit.getDefaultToolkit().createImage("logo.png"); Image image = Image.getInstance(awtImage, new Color(0x00, 0x00, 0xFF), true); image.setAbsolutePosition(100, 500); cb.addImage(image); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:FontSelectionPDF.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("FontSelectionPDF.pdf")); document.open();// ww w . java2s . c om String text = "Text Text Text Text Text Text Text, Text Text Text Text Text Text Text Text, Text Text Text Text Text Text Text Text Text Text Text Text Text "; FontSelector sel = new FontSelector(); sel.addFont(new Font(Font.TIMES_ROMAN, 12)); sel.addFont(new Font(Font.ZAPFDINGBATS, 12)); sel.addFont(new Font(Font.SYMBOL, 12)); Phrase ph = sel.process(text); document.add(new Paragraph(ph)); document.close(); }