Example usage for java.lang System err

List of usage examples for java.lang System err

Introduction

In this page you can find the example usage for java.lang System err.

Prototype

PrintStream err

To view the source code for java.lang System err.

Click Source Link

Document

The "standard" error output stream.

Usage

From source file:HelloWorldMultiplePDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*w  w  w  .ja  v  a2s . c om*/
        PdfWriter pdf = PdfWriter.getInstance(document, new FileOutputStream("HelloWorldMultiplePDF.pdf"));
        RtfWriter2 rtf = RtfWriter2.getInstance(document, new FileOutputStream("RTF_File.rtf"));
        HtmlWriter html = HtmlWriter.getInstance(document, new FileOutputStream("HTML_File.html"));

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

public static void main(String args[]) {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByName("javascript");
    engine.put("counter", 0);
    if (engine instanceof Compilable) {
        Compilable compEngine = (Compilable) engine;
        try {// w  w w  .j  av  a2 s  .  c  o  m
            CompiledScript script = compEngine
                    .compile("function count(){counter=counter+1;return counter;}; count();");
            System.out.println(script.eval());
            System.out.println(script.eval());
            System.out.println(script.eval());
        } catch (ScriptException e) {
            System.err.println(e);
        }
    } else {
        System.err.println("Engine can't compile code");
    }
}

From source file:whois.java

public static void main(String[] args) {

    Socket theSocket;/*ww  w  .  ja va2s  .  c  o  m*/
    DataInputStream theWhoisStream;
    PrintStream ps;

    try {
        theSocket = new Socket(hostname, port, true);
        ps = new PrintStream(theSocket.getOutputStream());
        for (int i = 0; i < args.length; i++)
            ps.print(args[i] + " ");
        ps.print("\r\n");
        theWhoisStream = new DataInputStream(theSocket.getInputStream());
        String s;
        while ((s = theWhoisStream.readLine()) != null) {
            System.out.println(s);
        }
    } catch (IOException e) {
        System.err.println(e);
    }

}

From source file:ImageAlignmentPDF.java

public static void main(String[] args) {

    Document document = new Document();
    try {/*from www .j a v  a2 s  . com*/
        PdfWriter.getInstance(document, new FileOutputStream("ImageAlignmentPDF.pdf"));
        document.open();

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

        Image imageCenter = Image.getInstance("logo.png");
        imageCenter.setAlignment(Image.MIDDLE);

        Image imageLeft = Image.getInstance("logo.png");
        imageLeft.setAlignment(Image.LEFT);

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

From source file:MainClass.java

public static void main(String[] args) {

    try {/*from  ww  w  .j  a  va 2  s.  c  o  m*/
        ZipFile zf = new ZipFile("your.zip");
        Enumeration e = zf.entries();
        while (e.hasMoreElements()) {
            ZipEntry ze = (ZipEntry) e.nextElement();
            String name = ze.getName();
            Date lastModified = new Date(ze.getTime());
            long uncompressedSize = ze.getSize();
            long compressedSize = ze.getCompressedSize();

            System.out.println(name);
            System.out.println(lastModified);
            System.out.println(uncompressedSize);
            System.out.println(compressedSize);

        }
    } catch (IOException ex) {
        System.err.println(ex);
    }
}

From source file:MainClass.java

public static void main(String[] Args) {
    String filepath = "C:/myFile.txt";
    File aFile = new File(filepath);
    FileOutputStream outputFile = null;
    if (aFile.isFile()) {
        File newFile = aFile;//  w ww .  j av  a  2s.  c  o m
        do {
            String name = newFile.getName();
            int period = name.indexOf('.');
            newFile = new File(newFile.getParent(),
                    name.substring(0, period) + "_old" + name.substring(period));
        } while (newFile.exists());
        aFile.renameTo(newFile);
    }
    try {
        outputFile = new FileOutputStream(aFile);
        System.out.println("myFile.txt output stream created");
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
    }
}

From source file:MirroringMarginsPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A5, 36, 72, 108, 180);
    try {/*  www  .ja  va2 s. c  o m*/
        PdfWriter.getInstance(document, new FileOutputStream("MirroringMarginsPDF.pdf"));
        document.open();

        document.add(new Paragraph("paragraph"));
        document.setMarginMirroring(true);
        document.add(new Paragraph("Starting on the next page, the margins will be mirrored."));
        for (int i = 0; i < 60; i++) {
            document.add(new Paragraph("paragraph"));
        }
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:EncryptedPDFWithAllowCopyPrinting.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from w  ww  . j  a  va2  s .c o  m*/
        PdfWriter writer = PdfWriter.getInstance(document,
                new FileOutputStream("EncryptedPDFWithAllowCopyPrinting.pdf"));
        //setEncryption(boolean strength, String userPassword, String ownerPassword, int permissions) 
        writer.setEncryption(PdfWriter.STRENGTH128BITS, "java2s.com", "World",
                PdfWriter.AllowCopy | PdfWriter.AllowPrinting);

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

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

        Table aTable = new Table(2, 2); // 4 rows, 4 columns
        aTable.setAutoFillEmptyCells(true);
        aTable.addCell("2.2");
        aTable.addCell("2.1");

        Table secondTable = new Table(2);
        secondTable.addCell("0.0");
        secondTable.addCell("0.1");
        aTable.insertTable(secondTable);

        aTable.addCell("2.2");

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

From source file:TextPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from   www. j ava 2s  . c  o m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TextPDF.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();

        cb.beginText();

        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        cb.setFontAndSize(bf, 12);

        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " Center", 250, 700, 0);

        cb.endText();
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}