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[] a) throws Exception {
    List list = Arrays.asList(new String[] { "A", "B", "C", "D" });

    FileOutputStream fos = new FileOutputStream("list.ser");
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(list);/*  w w  w  .j  a v  a  2 s . c  o  m*/
    oos.close();

    FileInputStream fis = new FileInputStream("list.ser");
    ObjectInputStream ois = new ObjectInputStream(fis);
    List anotherList = (List) ois.readObject();
    ois.close();

    System.out.println(anotherList);
}

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 www .  j  ava 2s . c  om*/

    document.add(new Paragraph("alert messages."));
    writer.setPageAction(PdfWriter.PAGE_OPEN,
            PdfAction.javaScript("app.alert('You have reached page 3');\r", writer));
    writer.setPageAction(PdfWriter.PAGE_CLOSE,
            PdfAction.javaScript("app.alert('You have left page 3');\r", writer));
    document.add(new Paragraph("Page 3"));

    document.close();
}

From source file:Main.java

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

    long[] l = { 1234567898765L, 12345678909876L };

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

    for (long j : l) {
        dos.writeLong(j);//from   w w  w . j av  a 2s.com
    }
    dos.flush();

    InputStream is = new FileInputStream("c:\\test.txt");
    DataInputStream dis = new DataInputStream(is);

    while (dis.available() > 0) {
        long k = dis.readLong();
        System.out.print(k);
    }
}

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  a v  a 2  s. c  om*/
    Chunk fox = new Chunk(Image.getInstance("fox.gif"), 0, -15);
    Chunk dog = new Chunk(Image.getInstance("dog.gif"), 0, -15);
    Paragraph p = new Paragraph("Quick brown ");
    p.add(fox);
    p.add(dog);
    document.add(p);
    document.close();
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    com.lowagie.text.Image img = null;
    Document document = new Document(new Rectangle(200, 280));
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();/*www. j  av a 2  s  . c o m*/
    img = com.lowagie.text.Image.getInstance("dog.png");
    img.setAbsolutePosition(15, 15);
    document.add(img);

    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  .ja v a2s. c  om
    List list1 = new List(List.UNORDERED, 30);
    list1.setListSymbol(new Chunk('*'));
    list1.add(new ListItem("A"));
    list1.add(new ListItem("B"));
    list1.add(new ListItem("C"));
    document.add(list1);

    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 av a 2 s . c om
    Chunk c;
    c = new Chunk("Quick brown fox jumps over the lazy dog.");
    c.setUnderline(new Color(0x00, 0xFF, 0x00), 5.0f, 0.0f, 0.0f, -0.5f,
            PdfContentByte.LINE_CAP_PROJECTING_SQUARE);

    document.add(c);
    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 w  w .  ja  v  a 2 s  .com
    PdfPTable table = new PdfPTable(4);
    PdfPTable nested1 = new PdfPTable(2);
    nested1.addCell("1.1");
    nested1.addCell("1.2");
    PdfPTable nested2 = new PdfPTable(1);
    nested2.addCell("20.1");
    nested2.addCell("20.2");
    for (int k = 0; k < 24; ++k) {
        if (k == 1) {
            table.addCell(nested1);
        } else if (k == 20) {
            table.addCell(new PdfPCell(nested2));
        } else {
            table.addCell("cell " + k);
        }
    }
    document.add(table);
    document.close();
}

From source file:MainClass.java

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

    List list = Arrays.asList(new String[] { "A", "B", "C", "D" });
    FileOutputStream fos = new FileOutputStream("list.ser");
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(list);/*  w  w  w.  j a  v  a  2s  . com*/
    oos.close();

    FileInputStream fis = new FileInputStream("list.ser");
    ObjectInputStream ois = new ObjectInputStream(fis);
    List anotherList = (List) ois.readObject();
    ois.close();

    System.out.println(anotherList);
}

From source file:ImagesTEXTWRAPPDF.java

public static void main(java.lang.String[] args) {
    Document document = new Document();
    try {/*from   ww w.jav a 2  s  . c om*/
        PdfWriter.getInstance(document, new FileOutputStream("ImagesTEXTWRAPPDF.pdf"));
        document.open();

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

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