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.setFullCompression();//ww w . ja  v  a2  s  . c om
    document.open();
    document.add(new Paragraph("Hello World"));
    document.close();
}

From source file:Main.java

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

    InputStream fin = new FileInputStream("a.dat");
    OutputStream fout = new FileOutputStream("a.dat.gz");
    GZIPOutputStream gzout = new GZIPOutputStream(fout);
    for (int c = fin.read(); c != -1; c = fin.read()) {
        gzout.write(c);//from ww w. j a  va  2s. com
    }
    gzout.close();
}

From source file:MainClass.java

public static void main(String[] args) throws IOException {
    DataOutputStream dos = new DataOutputStream(
            new BufferedOutputStream(new FileOutputStream(new File("temp.tmp"))));
    for (int i = 0; i < 10; i++)
        dos.writeInt(i);//from  w ww . j a v  a  2 s. c o m
    dos.close();

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileInputStream fin = new FileInputStream("a.gz");
    GZIPInputStream gzin = new GZIPInputStream(fin);
    FileOutputStream fout = new FileOutputStream("a.dat");
    for (int c = gzin.read(); c != -1; c = gzin.read()) {
        fout.write(c);/*from   ww  w .  ja  v a 2 s.  co m*/
    }
    fout.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("1.pdf"));
    writer.setEncryption(PdfWriter.STRENGTH128BITS, "Hello", "World",
            PdfWriter.AllowCopy | PdfWriter.AllowPrinting);
    document.open();//  w  w w  . j a va  2s. c  o m
    document.add(new Paragraph("Hello World"));
    document.close();
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    PdfReader reader = new PdfReader("HelloWorldMultiplePages.pdf");
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("HelloSelectedOdd.pdf"));
    reader.selectPages("o");
    stamper.close();//from   w w w .j  av a  2s. c  om
    reader = new PdfReader("HelloWorldMultiplePages.pdf");
    stamper = new PdfStamper(reader, new FileOutputStream("HelloSelectedEven.pdf"));
    reader.selectPages("e");
    stamper.close();
    reader = new PdfReader("HelloWorldMultiplePages.pdf");
    stamper = new PdfStamper(reader, new FileOutputStream("HelloSelected12379.pdf"));
    reader.selectPages("1-3, 7-9, !8");
    stamper.close();
}

From source file:Main.java

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

    byte[] buffer = { 65, 66, 67, 68, 69 };
    int i = 0;/*from  w w w .  ja v  a  2s .  com*/
    OutputStream os = new FileOutputStream("C://test.txt");
    FilterOutputStream fos = new FilterOutputStream(os);

    // writes buffer to the output stream
    fos.write(buffer, 2, 3);

    // forces byte contents to written out to the stream
    fos.flush();

    // create input streams
    FileInputStream fis = new FileInputStream("C://test.txt");

    while ((i = fis.read()) != -1) {
        // converts integer to the character
        char c = (char) i;

        System.out.println("Character read: " + c);
    }
    fos.close();
    fis.close();
}

From source file:MainClass.java

License:asdf

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter writer3 = PdfWriter.getInstance(document, new FileOutputStream("two_column_left.pdf"));
    writer3.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft);

    document.open();/*from ww  w  . jav a 2  s  .co m*/
    Paragraph hello = new Paragraph("(English:) hello, ");
    document.add(new Paragraph("asdf"));
    document.add(hello);
    document.close();
}

From source file:MainClass.java

License:asdf

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter writer1 = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    writer1.setViewerPreferences(PdfWriter.PageLayoutSinglePage);

    document.open();//from w  w w .  j av a 2 s  . co m
    Paragraph hello = new Paragraph("(English:) hello, ");
    document.add(new Paragraph("asdf"));
    document.add(hello);
    document.close();
}

From source file:Main.java

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

    byte[] buffer = { 65, 66, 67, 68, 69 };
    int i = 0;//from w w w.j av  a2 s . c o  m

    OutputStream os = new FileOutputStream("C://test.txt");
    FilterOutputStream fos = new FilterOutputStream(os);

    // writes buffer to the output stream
    fos.write(buffer);

    // forces byte contents to written out to the stream
    fos.flush();

    // create input streams
    FileInputStream fis = new FileInputStream("C://test.txt");

    while ((i = fis.read()) != -1) {
        // converts integer to the character
        char c = (char) i;
        System.out.println("Character read: " + c);
    }
    fos.close();
    fis.close();
}