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

public static void main(String args[]) {
    try {/*w w  w .j a  v a  2 s .  c  o  m*/
        MongoClient mongoClient = new MongoClient("localhost", 27017);
        DB db = mongoClient.getDB("test");
        System.out.println("Connect to database successfully");
        boolean auth = db.authenticate("myUserName", "myPassword".toCharArray());
        System.out.println("Authentication: " + auth);
        DBCollection coll = db.createCollection("mycol", null);
        System.out.println("Collection created successfully");
        coll = db.getCollection("mycol");
        System.out.println("Collection mycol selected successfully");
    } catch (Exception e) {
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
    }
}

From source file:DifferentTextBackgroundSuperscript.java

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

        Chunk c = new Chunk("background");
        c.setTextRise(8);
        c.setBackground(new Color(0xFF, 0x00, 0x00));

        Paragraph p = new Paragraph("The following chunk is ");
        p.add(c);
        document.add(p);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:LandscapePortraitPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4.rotate());
    try {//from www. j a  va2s  .  c  o  m
        PdfWriter.getInstance(document, new FileOutputStream("LandscapePortraitPDF.pdf"));
        document.open();
        document.add(new Paragraph("PageSize.A4.rotate()"));
        document.setPageSize(PageSize.A4);
        document.newPage();
        document.add(new Paragraph("This is portrait again"));
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:HTMLListsAtoEPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from ww  w. j a v a2 s .c  o  m*/
        HtmlWriter.getInstance(document, new FileOutputStream("HTMLListsAtoEPDF.html"));
        document.open();

        Paragraph paragraph = new Paragraph("A to E:");
        List list = new List(false, 10);
        list.add("A");
        list.add("B");
        list.add("C");
        list.add("D");
        list.add("E");
        paragraph.add(list);
        document.add(paragraph);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:StrokeClosePDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {// w  w  w .  jav  a  2s  .c o m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("StrokeClosePDF.pdf"));

        document.open();
        PdfContentByte cb = writer.getDirectContent();

        cb.setLineWidth(10f);
        cb.setRGBColorStrokeF(0f, 255f, 0f);
        cb.moveTo(100, 700);
        cb.lineTo(200, 800);
        cb.lineTo(200f, 250f);
        cb.lineTo(400f, 150f);

        cb.closePathFillStroke();

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

From source file:TestDSBind.java

public static void main(String args[]) throws SQLException, NamingException {

    // For this to work you will need to create the
    // directories /JNDI/JDBC on your file system first
    Context ctx = null;/*from   w  w  w  .  j  a va2 s  .c om*/
    try {
        Properties prop = new Properties();
        prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
        prop.setProperty(Context.PROVIDER_URL, "file:/JNDI/JDBC");
        ctx = new InitialContext(prop);
    } catch (NamingException ne) {
        System.err.println(ne.getMessage());
    }

    OracleDataSource ds = new OracleDataSource();
    ds.setDriverType("thin");
    ds.setServerName("dssw2k01");
    ds.setPortNumber(1521);
    ds.setDatabaseName("orcl");
    ds.setUser("scott");
    ds.setPassword("tiger");

    ctx.bind("joe", ds);
}

From source file:Main.java

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

    Path path = Paths.get("C:/tutorial/Java/JavaFX", "Topic.txt");
    long time = System.currentTimeMillis();
    FileTime fileTime = FileTime.fromMillis(time);
    try {//from w ww. jav  a 2  s .  c  o  m
        Files.setAttribute(path, "basic:lastModifiedTime", fileTime, LinkOption.NOFOLLOW_LINKS);
        Files.setAttribute(path, "basic:creationTime", fileTime, LinkOption.NOFOLLOW_LINKS);
        Files.setAttribute(path, "basic:lastAccessTime", fileTime, LinkOption.NOFOLLOW_LINKS);
    } catch (IOException e) {
        System.err.println(e);
    }

}

From source file:MainClass.java

public static void main(String[] args) {

    for (int i = 0; i < args.length; i++) {
        try {//from   w w  w. j a va2s.  co m
            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:UDPSend.java

public static void main(String args[]) {
    try {/*from   w w  w.ja  va 2  s . co m*/
        String host = "www.java2s.com";
        int port = 90;

        byte[] message = "Java Source and Support".getBytes();

        // Get the internet address of the specified host
        InetAddress address = InetAddress.getByName(host);

        // Initialize a datagram packet with data and address
        DatagramPacket packet = new DatagramPacket(message, message.length, address, port);

        // Create a datagram socket, send the packet through it, close it.
        DatagramSocket dsocket = new DatagramSocket();
        dsocket.send(packet);
        dsocket.close();
    } catch (Exception e) {
        System.err.println(e);
    }
}

From source file:InvocableTest.java

public static void main(String args[]) {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByName("javascript");
    try {/*from w w  w . ja  v  a 2  s  . c  o  m*/
        engine.eval("function myFunction(name){var output = '';"
                + "  for (i = 0; i <= name.length; i++) {output = name.charAt(i)+'-'+ output"
                + "  } return output;}");
        Invocable invokeEngine = (Invocable) engine;
        Object o = invokeEngine.invokeFunction("myFunction", "abcde");
        System.out.println(o);

    } catch (NoSuchMethodException e) {
        System.err.println(e);
    } catch (ScriptException e) {
        System.err.println(e);
    }
}