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

public static void main(String[] args) throws Exception {
    String fromFileName = "from.txt";
    String toFileName = "to.txt";
    FileChannel in = new FileInputStream(fromFileName).getChannel();
    FileChannel out = new FileOutputStream(toFileName).getChannel();

    ByteBuffer buff = ByteBuffer.allocateDirect(32 * 1024);

    while (in.read(buff) > 0) {
        buff.flip();//from   w w w  .  j  av a 2s  .  co  m
        out.write(buff);
        buff.clear();
    }

    in.close();
    out.close();
}

From source file:ClosingAPDFDocument.java

public static void main(String[] args) {
    Document document = new Document();
    try {// w w w.j  a v  a2s.  c o  m
        PdfWriter.getInstance(document, new FileOutputStream("ClosingAPDFDocument.pdf"));
        document.open();

        document.add(new Paragraph("some text"));
    } 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 {
    String fromFileName = args[0];
    String toFileName = args[1];/*w  w w  . j  a v a 2s . com*/
    FileChannel in = new FileInputStream(fromFileName).getChannel();
    FileChannel out = new FileOutputStream(toFileName).getChannel();

    ByteBuffer buff = ByteBuffer.allocate(32 * 1024);

    while (in.read(buff) > 0) {
        buff.flip();
        out.write(buff);
        buff.clear();
    }

    in.close();
    out.close();
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream("HelloWorldMetadata.pdf"));
    RtfWriter2.getInstance(document, new FileOutputStream("HelloWorldMetadata.rtf"));
    HtmlWriter.getInstance(document, new FileOutputStream("HelloWorldMetadata.htm"));
    document.addTitle("title");
    document.addSubject("subject");
    document.addKeywords("Metadata, iText");
    document.addCreator("java2s");
    document.addAuthor("author");
    document.addHeader("Expires", "0");
    document.open();// w w w.j ava 2s.  co m
    document.add(new Paragraph("Hello World"));
    document.close();
}

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");

    // create a output and input as a xml file
    FileOutputStream fos = new FileOutputStream("properties.xml");
    FileInputStream fis = new FileInputStream("properties.xml");

    // store the properties in the specific xml
    prop.storeToXML(fos, null);/*from  w  w w .  j  a va  2  s.c  o  m*/

    // load from the xml that we saved earlier
    prop.loadFromXML(fis);

    // print the properties list
    prop.list(System.out);

}

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.  com
    PdfPTable table = new PdfPTable(3);
    PdfPCell cell = new PdfPCell(new Paragraph("header"));
    cell.setColspan(3);
    table.addCell(cell);
    table.addCell("1.1");
    table.addCell("2.1");
    table.addCell("3.1");
    table.addCell("1.2");
    table.addCell("2.2");
    table.addCell("3.2");
    document.add(table);
    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  .j  ava 2s  .  com
    PdfPTable table = new PdfPTable(3);
    PdfPCell cell = new PdfPCell(new Paragraph("header"));

    table.addCell(cell);
    table.addCell("1.1");
    table.addCell("2.1");
    table.addCell("3.1");
    table.addCell("1.2");
    table.addCell("2.2");
    table.addCell("3.2");
    document.add(table);
    document.close();
}

From source file:MultipleLinedTextPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from ww w  . ja  va  2s.co m
        PdfWriter.getInstance(document, new FileOutputStream("MultipleLinedTextPDF.pdf"));
        document.open();

        Chunk chunk;
        chunk = new Chunk("Multiple lines");
        chunk.setUnderline(new Color(0xFF, 0x00, 0x00), 0.0f, 0.3f, 0.0f, 0.4f, PdfContentByte.LINE_CAP_ROUND);
        chunk.setUnderline(new Color(0x00, 0xFF, 0x00), 3.0f, 0.0f, 0.0f, -0.5f,
                PdfContentByte.LINE_CAP_PROJECTING_SQUARE);
        chunk.setUnderline(new Color(0x00, 0x00, 0xFF), 0.0f, 0.2f, 15.0f, 0.0f, PdfContentByte.LINE_CAP_BUTT);
        document.add(chunk);

    } 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  v a  2 s. c o m*/
    PdfPTable table = new PdfPTable(3);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3"));
    cell.setColspan(3);
    table.addCell(cell);
    table.addCell("1.1");
    table.addCell("2.1");
    table.addCell("3.1");
    table.addCell("1.2");
    table.addCell("2.2");
    table.addCell("3.2");
    document.add(table);
    document.close();
}

From source file:ImageAbsolutePositionsPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from   ww  w. j  a v  a2s  .c  om*/
        PdfWriter.getInstance(document, new FileOutputStream("ImageAbsolutePositionsPDF.pdf"));
        document.open();

        Image png = Image.getInstance("logo.png");
        png.setAbsolutePosition(170, 250);

        document.add(png);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}