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 IOException { double[] dbuf = { 65.56, 66.89, 67.98, 68.82, 69.55, 70.37 }; FileOutputStream fos = new FileOutputStream("c:\\test.txt"); DataOutputStream dos = new DataOutputStream(fos); for (double d : dbuf) { dos.writeDouble(d);/*from w w w .j av a2s . com*/ } dos.flush(); InputStream is = new FileInputStream("c:\\test.txt"); DataInputStream dis = new DataInputStream(is); while (dis.available() > 0) { double c = dis.readDouble(); System.out.print(c + " "); } }
From source file:MainClass.java
public static void main(String[] args) throws IOException { DataOutputStream out2 = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("Data.txt"))); out2.writeDouble(3.14159);/*from w w w . java 2 s. co m*/ out2.writeUTF("Square root of 2"); out2.close(); DataInputStream in5 = new DataInputStream(new BufferedInputStream(new FileInputStream("Data.txt"))); System.out.println(in5.readDouble()); System.out.println(in5.readUTF()); }
From source file:DrawArcPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w . ja v a 2 s. c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("DrawArcPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate template = cb.createTemplate(500, 200); template.setLineWidth(2f); template.arc(20f, 20f, 00f, -40f, 90f, 45f); template.stroke(); template.setLineWidth(12f); cb.addTemplate(template, 0, 1, -1, 0, 500, 200); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:RawDataFromImageFileAndManipulationPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from ww w . j av a 2s. c om PdfWriter.getInstance(document, new FileOutputStream("RawDataFromImageFileAndManipulationPDF.pdf")); document.open(); RandomAccessFile rf = new RandomAccessFile("logo.png", "r"); int size = (int) rf.length(); byte imext[] = new byte[size]; rf.readFully(imext); rf.close(); for (int i = 0; i < imext.length; i++) { imext[i] = (byte) (imext[i] + 3); } Image img1 = Image.getInstance(100, 100, 3, 8, imext); img1.setAbsolutePosition(200, 200); document.add(img1); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:MainClass.java
public static void main(String[] args) { Employee e = new Employee(); e.name = "Jor Lee"; e.address = "USA"; e.SSN = 11122333;/*ww w.j av a 2 s. c om*/ e.number = 101; try { FileOutputStream fileOut = new FileOutputStream("employee.ser"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(e); out.close(); fileOut.close(); } catch (IOException i) { i.printStackTrace(); } }
From source file:DefaultPageSizeA4PDF.java
public static void main(String[] args) { Document document = new Document(); try {/*ww w. ja v a 2 s. co m*/ PdfWriter.getInstance(document, new FileOutputStream("DefaultPageSizeA4PDF.pdf")); document.open(); document.add(new Paragraph("The default PageSize is DIN A4.")); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:FontFactoryStylesBoldPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*ww w. j a v a2s. c o m*/ PdfWriter.getInstance(document, new FileOutputStream("FontFactoryStylesBoldPDF.pdf")); document.open(); FontFactory.register("c:\\windows\\fonts\\arialbd.ttf"); document.add(new Phrase("bold ", FontFactory.getFont("Arial", 8, Font.BOLD))); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:PDFMetaTitle.java
public static void main(String[] args) { Document document = new Document(); try {/*w ww. ja v a 2 s.co m*/ PdfWriter.getInstance(document, new FileOutputStream("PDFMetaTitle.pdf")); document.addTitle("Hello World example"); document.open(); document.add(new Paragraph("Hello World")); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } 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();/*from w ww . ja v a 2 s . co m*/ PdfPTable table = new PdfPTable(3); PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3")); cell.setColspan(3); table.addCell(cell); table.addCell("2"); table.setSpacingBefore(15f); document.add(table); table.setSpacingAfter(10f); document.add(table); document.close(); }
From source file:Main.java
public static void main(String args[]) throws Exception { Preferences prefsRoot = Preferences.userRoot(); Preferences myPrefs = prefsRoot.node("PreferenceExample"); myPrefs.put("A", "a"); myPrefs.put("B", "b"); myPrefs.put("C", "c"); FileOutputStream fos = new FileOutputStream("prefs.xml"); myPrefs.exportSubtree(fos);/*ww w . ja v a 2s. com*/ fos.close(); }