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) throws Exception {
    String url = "jdbc:odbc:databaseName";
    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String user = "guest";
    String password = "guest";

    String theStatement = "SELECT lastname, firstname FROM autors";

    try {//from   w w w  . ja  v  a  2s  .co m
        Class.forName(driver);
        Connection connection = DriverManager.getConnection(url, user, password);
        Statement queryAuthors = connection.createStatement();
        ResultSet theResults = queryAuthors.executeQuery(theStatement);

        queryAuthors.close();
    } catch (ClassNotFoundException cnfe) {
        System.err.println(cnfe);
    } catch (SQLException sqle) {
        String sqlMessage = sqle.getMessage();
        String sqlState = sqle.getSQLState();
        int vendorCode = sqle.getErrorCode();
        System.err.println("Exception occurred:");
        System.err.println("Message: " + sqlMessage);
        System.err.println("SQL state: " + sqlState);
        System.err.println("Vendor code: " + vendorCode + "\n----------------");
    }
}

From source file:ImagesTEXTWRAPPDF.java

public static void main(java.lang.String[] args) {
    Document document = new Document();
    try {/*  w ww. j  ava  2s .co  m*/
        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();
}

From source file:ImagesDefaultWRAPPDF.java

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

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

        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();
}

From source file:LayerImageOnTextPDF.java

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

        Paragraph p = new Paragraph();
        for (int i = 0; i < 100; i++)
            p.add(new Chunk("Text Text Text Text Text Text Text Text "));
        document.add(p);

        Image img = Image.getInstance("logo.png");
        img.setAbsolutePosition(100, 500);
        document.add(img);

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

From source file:GuaranteeAFile.java

public static void main(String[] args) {

    String filename = "C:/myFile.txt";
    File aFile = new File(filename);
    if (aFile.isDirectory()) {
        System.out.println("The path " + aFile.getPath() + " does not specify a file. Program aborted.");
        System.exit(1);//from w  w w  . j a  v  a 2  s. c om
    }
    if (!aFile.isFile()) {
        aFile = aFile.getAbsoluteFile();
        File parentDir = new File(aFile.getParent());
        if (!parentDir.exists()) {
            parentDir.mkdirs();
        }
    }
    FileOutputStream outputFile = null;
    try {
        outputFile = new FileOutputStream(aFile, true);
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
    }
}

From source file:ImagesUNDERLYINGPDF.java

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

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

        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();
}

From source file:ChainedExceptionDemo.java

public static void main(String[] args) {
    String driver = "com.mysql.jdbc.Driver";
    String connectionURL = "jdbc:mysql://127.0.0.1:3306/sample";
    try {//from  w  ww .  j a  v a 2 s. com
        Class.forName(driver);
    } catch (java.lang.ClassNotFoundException e) {
        e.printStackTrace();
    }
    try {
        conn = DriverManager.getConnection(connectionURL);
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT * FROM NONEXISTINGTABLE");
        rs.next();
        rs.close();
    } catch (SQLException sx) {
        for (Throwable e : sx) {
            System.err.println("Error encountered: " + e);
        }
    }
}

From source file:Main.java

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

    Path path = Paths.get("c:/home/tutorial/Java/JavaFX/Topic.txt");
    Path new_path = Paths.get("/home/tutorial/Java/JavaFX/new_Topic.txt");

    //use of fromString
    Set<PosixFilePermission> permissions = PosixFilePermissions.fromString("rw-r--r--");
    try {/*from  ww  w  .j ava2  s  . c  o  m*/
        Files.setPosixFilePermissions(new_path, permissions);
    } catch (IOException e) {
        System.err.println(e);
    }
}

From source file:TableWithImagePDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//w w w  .  j  ava  2  s .  co m
        PdfWriter.getInstance(document, new FileOutputStream("TableWithImagePDF.pdf"));

        document.open();

        Table table = new Table(1);
        table.addCell(new Cell(Image.getInstance("logo.png")));
        Cell c1 = new Cell();
        c1.add(Image.getInstance("logo.png"));
        table.addCell(c1);

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

From source file:RunJavaScript.java

public static void main(String args[]) {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByName("javascript");
    try {//from   w  ww . j  a  v a2s  .  c  o m
        Double hour = (Double) engine.eval("var date = new Date();" + "date.getHours();");
        String msg;
        if (hour < 10) {
            msg = "Good morning";
        } else if (hour < 16) {
            msg = "Good afternoon";
        } else if (hour < 20) {
            msg = "Good evening";
        } else {
            msg = "Good night";
        }
        System.out.println(hour);
        System.out.println(msg);
    } catch (ScriptException e) {
        System.err.println(e);
    }
}