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.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();/*from  ww w  . jav  a  2 s  .  com*/
    Phrase text = new Phrase("this is a test. ");
    Font font = new Font(Font.HELVETICA, 14, Font.BOLD);
    Chapter chapter1 = new Chapter(new Paragraph("This is the title.", font), 1);
    chapter1.add(text);
    Section section1 = chapter1.addSection("Quick", 0);
    section1.add(text);
    section1.add(text);
    section1.add(text);
    document.add(chapter1);
    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();/*w  w  w . j ava2 s.c  o m*/
    Chunk space = new Chunk("asdf");
    Phrase phrase2 = new Phrase(new Chunk("asdf", new Font(Font.TIMES_ROMAN)));
    Paragraph paragraph = new Paragraph();
    paragraph.add(space);
    paragraph.add(phrase2);
    paragraph.setSpacingBefore(20);
    paragraph.setSpacingAfter(10);
    paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
    document.add(paragraph);

    document.close();
}

From source file:ParagraphAttributesSpaceAfterPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from  www  .  jav a  2 s. c om*/
        PdfWriter.getInstance(document, new FileOutputStream("ParagraphAttributesSpaceAfterPDF.pdf"));
        document.open();
        Paragraph p = new Paragraph(
                "This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. ");

        p.setSpacingAfter(15f);
        document.add(p);
        document.add(p);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String fromFileName = "from.txt";
    String toFileName = "to.txt";
    BufferedInputStream in = new BufferedInputStream(new FileInputStream(fromFileName));
    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(toFileName));
    byte[] buff = new byte[32 * 1024];
    int len;//from w ww .  j  a  v  a  2 s .  c  o  m
    while ((len = in.read(buff)) > 0)
        out.write(buff, 0, len);
    in.close();
    out.close();
}

From source file:ParagraphAttributesSpaceBeforePDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from ww  w.  ja  v a 2s  .  c o m*/
        PdfWriter.getInstance(document, new FileOutputStream("ParagraphAttributesSpaceBeforePDF.pdf"));
        document.open();
        Paragraph p = new Paragraph(
                "This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. ");

        p.setSpacingBefore(15f);
        document.add(p);
        document.add(p);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(null,
            null);//www. j a  v  a2 s  .  co m

    OutputStream fos = new BufferedOutputStream(new FileOutputStream("outfile.ps"));
    StreamPrintService service = factories[0].getPrintService(fos);

}

From source file:AnnotatedImageHyperLink.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    try {//w ww.  j a  v a2 s  .  c o  m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("AnnotatedImageHyperLink.pdf"));

        document.open();

        Image png = Image.getInstance("logo.png");
        png.setAnnotation(new Annotation(0, 0, 0, 0, "http://www.java2s.com"));
        png.setAbsolutePosition(100f, 550f);
        document.add(png);

    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    double data[] = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6 };
    DataOutputStream fout = new DataOutputStream(new DeflaterOutputStream(new FileOutputStream("data.dat")));
    fout.writeInt(data.length);//  www .jav a  2  s .  c o  m

    for (double d : data)
        fout.writeDouble(d);

    DataInputStream fin = new DataInputStream(new InflaterInputStream(new FileInputStream("data.dat")));
    int num = fin.readInt();

    double avg = 0.0;
    double d;

    for (int i = 0; i < num; i++) {
        d = fin.readDouble();
        avg += d;
        System.out.print(d + " ");
    }
    fin.close();
    fout.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();/* www . ja  v a 2s.  c  o m*/

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100);
    PdfPCell cell = new PdfPCell(
            new Paragraph("Quick brown fox jumps over the lazy dog. Quick brown fox jumps over the lazy dog."));
    table.addCell("default leading / spacing");
    table.addCell(cell);
    table.addCell("absolute leading: 20");
    cell.setLeading(20f, 0f);
    table.addCell(cell);
    table.addCell("absolute leading: 3; relative leading: 1.2");
    cell.setLeading(3f, 1.2f);
    table.addCell(cell);
    table.addCell("absolute leading: 0; relative leading: 1.2");
    cell.setLeading(0f, 1.2f);
    table.addCell(cell);
    table.addCell("no leading at all");
    cell.setLeading(0f, 0f);
    table.addCell(cell);

    document.add(table);
    document.close();
}