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) {
    FTPClient client = new FTPClient();
    FileOutputStream fos = null;/* ww w .j  av a 2 s . c o m*/

    client.connect("ftp.domain.com");
    client.login("admin", "secret");

    String filename = "sitemap.xml";
    fos = new FileOutputStream(filename);

    client.retrieveFile("/" + filename, fos);
    fos.close();
    client.disconnect();
}

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  .  jav a  2s  .com
    document.add(Image.getInstance("animated.gif"));
    GifImage img = new GifImage("animated.gif");
    int frames = img.getFrameCount();
    document.add(new Paragraph("There are " + frames + " frames in the animated gif file."));
    for (int i = 0; i < frames;) {
        ++i;
        document.add(img.getImage(i));
    }
    document.close();
}

From source file:HelloWorldPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*  w  ww.j  ava2  s.  c  o m*/
        PdfWriter.getInstance(document, new FileOutputStream("HelloWorldPDF.pdf"));
        document.open();
        document.add(new Paragraph("Hello World"));
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:ExtraStyleSTRIKETHRUPDF.java

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

        document.add(new Chunk("underline",
                FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.STRIKETHRU)));
    } catch (Exception e) {
        System.err.println(e.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("ttc.pdf"));

    document.open();// ww w.  j  a  v  a  2  s  .c  om
    BaseFont bf;
    Font font;
    bf = BaseFont.createFont("c:/windows/fonts/msgothic.ttc,0", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    font = new Font(bf, 12);
    System.err.println(bf.getClass().getName());
    document.add(new Paragraph("abcde", font));
    document.add(new Paragraph("\u7f85\u751f\u9580", font));
    String[] names = BaseFont.enumerateTTCNames("c:/windows/fonts/msgothic.ttc");
    for (int i = 0; i < names.length; i++) {
        document.add(new Paragraph("font " + i + ": " + names[i], font));
    }
    document.close();
}

From source file:Copy.java

public static void main(String args[]) throws Exception {
    String elements[] = { "Irish Setter", "Poodle", "English Setter", "Gordon Setter", "Pug" };
    Set set = new HashSet(Arrays.asList(elements));
    Set set2 = ((Set) ((HashSet) set).clone());
    System.out.println(set2);/*from  w  w  w .  j  av  a 2s .  c om*/
    FileOutputStream fos = new FileOutputStream("set.ser");
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(set);
    oos.close();
    FileInputStream fis = new FileInputStream("set.ser");
    ObjectInputStream ois = new ObjectInputStream(fis);
    Set set3 = (Set) ois.readObject();
    ois.close();
    System.out.println(set3);
}

From source file:NegativeLeadingPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {// w w  w  .  java  2s . c om
        PdfWriter.getInstance(document, new FileOutputStream("NegativeLeadingPDF.pdf"));
        document.open();
        document.add(new Phrase(16,
                "Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text "));
        document.add(new Phrase(-16,
                "Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text "));
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:SpecialSymbolPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from w  w w  .j a v  a 2 s.  c om
        PdfWriter.getInstance(document, new FileOutputStream("SpecialSymbolPDF.pdf"));
        document.open();
        for (int i = 913; i < 970; i++) {
            document.add(Phrase.getInstance(" " + i + ": " + (char) i));
        }
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:CopyBytes.java

public static void main(String[] args) throws IOException {
    File inputFile = new File("input.txt");
    File outputFile = new File("output.txt");

    FileInputStream in = new FileInputStream(inputFile);
    FileOutputStream out = new FileOutputStream(outputFile);
    int c;/*from   www.  j  a  va2  s.c  om*/

    while ((c = in.read()) != -1)
        out.write(c);

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

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    PdfReader reader = new PdfReader("1.pdf");
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("Encrypted1.pdf"));
    stamper.setEncryption("Hello".getBytes(), "World".getBytes(), PdfWriter.AllowPrinting | PdfWriter.AllowCopy,
            PdfWriter.STRENGTH40BITS);/*from ww  w . j  a v a 2s . c  o m*/
    stamper.close();

    getEncryptionInformation("1.pdf", null);
    getEncryptionInformation("Encrypted1.pdf", "World");
}