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:TableColumnRowCountPDF.java

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

        Table table = new Table(2, 2); // 2 rows, 2 columns
        table.addCell("0.0");
        table.addCell("0.1");
        table.addCell("1.0");
        table.addCell("1.1");
        document.add(table);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:AddingChunkToParagraphPDF.java

public static void main(String[] args) {
    try {/*w  ww  .j  a  va  2s.  com*/
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document,
                new FileOutputStream("AddingChunkToParagraphPDF.pdf"));
        document.open();
        Paragraph p = new Paragraph();
        p.add(new Chunk("Font.TIMES_ROMAN", new Font(Font.TIMES_ROMAN, 12)));
        document.add(new Paragraph(p));

        document.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("2.pdf"));
    document.open();/*  ww  w.  jav  a  2 s  . c  om*/
    PdfPTable table = new PdfPTable(3);
    PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3"));
    cell.setColspan(3);
    table.addCell(cell);
    table.addCell("1");
    table.addCell("2");
    table.addCell("3");
    table.setWidthPercentage(100);
    document.add(table);
    table.setWidthPercentage(50);
    table.setHorizontalAlignment(Element.ALIGN_RIGHT);
    document.add(table);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    document.add(table);
    document.close();
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    Deflater def = new Deflater();
    byte[] input = new byte[1024];
    byte[] output = new byte[1024];

    FileInputStream fin = new FileInputStream("a.dat");
    FileOutputStream fout = new FileOutputStream("b.dat");

    int numRead = fin.read(input);

    def.setInput(input, 0, numRead);//from   www . j ava 2s . c o m

    while (!def.needsInput()) {
        int numCompressedBytes = def.deflate(output, 0, output.length);
        if (numCompressedBytes > 0) {
            fout.write(output, 0, numCompressedBytes);
        }
    }
    def.finish();
    fin.close();
    fout.flush();
    fout.close();
    def.reset();
}

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 w w  .j  av a  2 s  . c  o  m*/
    Font font = new Font(Font.COURIER, 20);
    Chunk chunk = new Chunk("this is a test.", font);
    chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, 0f, new Color(0xFF, 0x00, 0x00));
    document.add(new Paragraph(chunk));

    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  va 2 s  .  c o m
    Font font = new Font(Font.COURIER, 20);
    Chunk chunk = new Chunk("this is a test.", font);
    chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_INVISIBLE, 0f, new Color(0xFF, 0x00, 0x00));
    document.add(new Paragraph(chunk));

    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  va2s  .  c o  m*/
    Font font = new Font(Font.COURIER, 20);
    Chunk chunk = new Chunk("this is a test.", font);
    chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL, 0f, new Color(0xFF, 0x00, 0x00));
    document.add(new Paragraph(chunk));

    document.close();
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document(PageSize.A4);
    PdfWriter.getInstance(document, new FileOutputStream("1.pdf"));
    document.open();//  ww  w .  ja  v a2 s  .c om
    document.add(new Paragraph("this"));
    document.newPage();
    Paragraph hello = new Paragraph("paragraph");
    Chapter universe = new Chapter("To the Universe:", 1);
    Section section;
    section = universe.addSection("World:");
    section.add(hello);
    section = universe.addSection("Sun:");
    section.add(hello);
    section = universe.addSection("Moon:");
    section.add(hello);
    section = universe.addSection("Stars:");
    section.add(hello);
    document.add(universe);
    document.close();
}

From source file:MainClass.java

License:asdf

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();/*from  w ww  .j a  v a2  s . c o  m*/
    Chunk space = new Chunk("asdf");
    Paragraph paragraph = new Paragraph();
    paragraph.add(space);
    paragraph.setAlignment(Element.ALIGN_RIGHT);
    document.add(paragraph);

    document.close();
}

From source file:MainClass.java

License:asdf

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();//from  w w  w  .  j a v a 2s .c o m
    Chunk space = new Chunk("asdf");
    Paragraph paragraph = new Paragraph();
    paragraph.add(space);
    paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
    document.add(paragraph);

    document.close();
}