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 {
    Properties prop = new Properties();

    prop.put("Chapter Count", "200");
    prop.put("Tutorial Count", "15");
    prop.put("tutorial", "java2s.com");

    // 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, "Properties Example");

    // print the xml
    while (fis.available() > 0) {
        System.out.print((char) fis.read());
    }/*from   ww w. j av a  2  s  .c o  m*/

}

From source file:SpotColorsGrayPDF.java

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

        PdfContentByte cb = writer.getDirectContent();

        PdfSpotColor spc_g = new PdfSpotColor("PANTONE 100 CV", 0.5f, new GrayColor(0.9f));

        cb.setColorStroke(spc_g, .5f);
        cb.setLineWidth(10f);
        cb.rectangle(100, 700, 100, 100);
        cb.stroke();
    } catch (Exception de) {
        de.printStackTrace();
    }
    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();/*from   w ww .j a v  a2s  . com*/
    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.setAlignment(Element.ALIGN_JUSTIFIED);
    document.add(paragraph);

    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();//from  w w w.j  a v a 2s  . c om
    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.setIndentationRight(20);

    document.add(paragraph);

    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();/*from   w  w  w .  j a va2 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.setIndentationLeft(20);
    paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
    document.add(paragraph);

    document.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    SortedProperties sp = new SortedProperties();
    sp.put("B", "value B");
    sp.put("C", "value C");
    sp.put("A", "value A");
    sp.put("D", "value D");
    FileOutputStream fos = new FileOutputStream("sp.props");
    sp.store(fos, "sorted props");
}

From source file:SpotColorsTintPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from  w  ww  .  j av a 2s.  c  o  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpotColorsTintPDF.pdf"));
        document.open();

        PdfContentByte cb = writer.getDirectContent();

        PdfSpotColor spc_g = new PdfSpotColor("PANTONE 100 CV", 0.5f, new GrayColor(0.9f));

        cb.setColorStroke(spc_g, .5f);
        cb.setLineWidth(10f);
        cb.setColorFill(spc_g, spc_g.getTint());
        cb.rectangle(100, 700, 100, 100);
        cb.fill();
    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document(new Rectangle(144, 115));
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    writer.setPdfVersion(PdfWriter.VERSION_1_5);
    writer.setViewerPreferences(PdfWriter.PageModeFullScreen);
    document.open();//w w  w  . j  a  v a2s . c o  m

    Image img0 = Image.getInstance("0.gif");
    img0.setAbsolutePosition(0, 0);
    writer.setTransition(new PdfTransition(PdfTransition.OUTBOX, 3));
    document.add(img0);
    document.newPage();

    Image img1 = Image.getInstance("1.gif");
    img1.setAbsolutePosition(0, 0);
    writer.setTransition(new PdfTransition(PdfTransition.INBOX, 2));
    writer.setDuration(1);
    document.add(img1);
    document.newPage();

    document.close();
}

From source file:MainClass.java

public static void main(String[] args) {

    for (int i = 0; i < args.length; i++) {
        try {//from w  w w .  ja  v  a 2 s.c  om
            FileInputStream fin = new FileInputStream(args[i]);
            FileOutputStream fout = new FileOutputStream(args[i] + DEFLATE_SUFFIX);
            DeflaterOutputStream dos = new DeflaterOutputStream(fout);
            for (int c = fin.read(); c != -1; c = fin.read()) {
                dos.write(c);
            }
            dos.close();
            fin.close();
        } catch (IOException ex) {
            System.err.println(ex);
        }
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    OutputStream fos = new BufferedOutputStream(new FileOutputStream("filename.ps"));
    DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
    StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor,
            DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());

    StreamPrintService service = factories[0].getPrintService(fos);
    Class[] cats = service.getSupportedAttributeCategories();
    for (int j = 0; j < cats.length; j++) {
        Attribute attr = (Attribute) service.getDefaultAttributeValue(cats[j]);

        if (attr != null) {
            String attrName = attr.getName();
            String attrValue = attr.toString();

            Object o = service.getSupportedAttributeValues(attr.getCategory(), null, null);
            if (o.getClass().isArray()) {
                for (int k = 0; k < Array.getLength(o); k++) {
                    Object o2 = Array.get(o, k);
                    System.out.println(o2);
                }/* w  w  w.  j a  v a2s  .  co m*/
            }
        }
    }
}