Example usage for java.io FileOutputStream FileOutputStream

List of usage examples for java.io FileOutputStream FileOutputStream

Introduction

In this page you can find the example usage for java.io FileOutputStream FileOutputStream.

Prototype

public FileOutputStream(FileDescriptor fdObj) 

Source Link

Document

Creates a file output stream to write to the specified file descriptor, which represents an existing connection to an actual file in the file system.

Usage

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"));
    writer.setViewerPreferences(PdfWriter.PageModeUseThumbs);
    document.open();/*from ww w. j a  v  a  2s.  co  m*/
    Paragraph hello = new Paragraph("(English:) hello, ");
    document.add(new Paragraph("1. To the Universe:"));
    document.add(hello);

    PdfPageLabels pageLabels = new PdfPageLabels();
    pageLabels.addPageLabel(1, PdfPageLabels.LOWERCASE_ROMAN_NUMERALS);
    pageLabels.addPageLabel(5, PdfPageLabels.DECIMAL_ARABIC_NUMERALS);
    pageLabels.addPageLabel(8, PdfPageLabels.DECIMAL_ARABIC_NUMERALS, "A-", 8);
    writer.setPageLabels(pageLabels);
    document.close();
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    double[] dbuf = { 12.34, 34.45, 67.78, 88.88, 66.66, 77.33 };

    FileOutputStream fos = new FileOutputStream("c:\\test.txt");
    DataOutputStream dos = new DataOutputStream(fos);

    for (double d : dbuf) {
        dos.writeDouble(d);//from w  w w  . ja va  2s.  c o m
    }
    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:iTextVersion.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*  ww w  .  jav a2  s.  c  om*/
        PdfWriter.getInstance(document, new FileOutputStream("Version.pdf"));
        document.open();
        document.add(new Paragraph("This page was made using " + Document.getVersion()));
    } catch (Exception 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 ww w  . j a va  2 s.c  om*/
    Image img = Image.getInstance("dog.jpg");
    PdfPTable table = new PdfPTable(1);

    table.addCell(new PdfPCell(img, true));
    document.add(table);

    document.close();
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    float[] fbuf = { 12.34f, 23.34f, 45.56f, 67.78f, 12.55f, 77.88f };

    FileOutputStream fos = new FileOutputStream("c:\\test.txt");
    DataOutputStream dos = new DataOutputStream(fos);
    for (float f : fbuf) {
        dos.writeFloat(f);/*from  w  w  w.  j a  v a2 s  .c  o m*/
    }
    dos.flush();
    InputStream is = new FileInputStream("c:\\test.txt");
    DataInputStream dis = new DataInputStream(is);

    while (dis.available() > 0) {
        float c = dis.readFloat();
        System.out.print(c);
    }
}

From source file:GreekListsPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from w  ww.j ava 2  s  . c  o  m*/
        PdfWriter.getInstance(document, new FileOutputStream("GreekListsPDF.pdf"));
        document.open();

        GreekList greek = new GreekList(15);
        greek.setGreekLower(true);
        greek.add(new ListItem("first item"));
        greek.add(new ListItem("second item"));
        for (int i = 3; i < 20; i++) {
            greek.add(i + "th item");
        }
        document.add(greek);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:ImagesAlignmentWithTextPDF.java

public static void main(java.lang.String[] args) {
    Document document = new Document();
    try {// www  .java2 s . c o m
        PdfWriter.getInstance(document, new FileOutputStream("ImagesAlignmentWithTextPDF.pdf"));
        document.open();

        Image imageRight = Image.getInstance("logo.png");
        imageRight.setAlignment(Image.RIGHT | Image.TEXTWRAP);

        for (int i = 0; i < 100; i++) {
            document.add(new Phrase("Text "));
        }
        document.add(imageRight);
        for (int i = 0; i < 150; i++) {
            document.add(new Phrase("Text "));
        }
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

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 w  w w.  j  av a2  s.  c om*/
    PdfContentByte cb = writer.getDirectContent();
    String text = "this is a test";
    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
    cb.setFontAndSize(bf, 12);
    cb.beginText();

    cb.setTextMatrix(50, 700);
    cb.showText(text);

    cb.endText();
    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  ww . j  a v  a 2s .c om
    Image img = Image.getInstance("dog.jpg");
    PdfPTable table = new PdfPTable(1);

    table.addCell(new PdfPCell(img, false));
    document.add(table);

    document.close();
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document1 = new Document();
    PdfWriter.getInstance(document1, new FileOutputStream("font_not_embedded.pdf"));

    document1.open();/*from  www  .  j  a va  2 s.c om*/
    BaseFont bf_not_embedded = BaseFont.createFont("c:\\windows\\fonts\\comic.ttf", BaseFont.CP1252,
            BaseFont.NOT_EMBEDDED);
    Font font_not_embedded = new Font(bf_not_embedded, 12);

    document1.add(new Paragraph("quick brown fox jumps over the lazy dog", font_not_embedded));

    document1.close();

}