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

public static void main(String args[]) {
    ListExampleV1 listExample = new ListExampleV1();
    listExample.createLists();//  ww w  . j a v  a 2s.  co  m

    uniqueList.add("Value1");
    uniqueList.add("Value1");
    System.err.println(uniqueList); // should contain only one element

    cursorList.add("Element1");
    cursorList.add("Element2");
    cursorList.add("Element3");

    ListIterator iterator = cursorList.listIterator();
    iterator.next(); // cursor now between 0th and 1st element
    iterator.add("Element2.5"); // adds this between 0th and 1st element

    System.err.println(cursorList); // modification done to the iterator are visible in the list
}

From source file:MainClass.java

public static void main(String[] av) {

    String input = "4096.251";
    NumberFormat defForm = NumberFormat.getInstance();

    try {/*w  w w .  ja v  a 2  s .c o m*/
        Number d = defForm.parse(input);
        System.out.println(input + " parses as " + d + " and formats as " + defForm.format(d));
    } catch (ParseException pe) {
        System.err.println(input + "not parseable!");
    }
}

From source file:MainClass.java

public static void main(String[] args) {

    String host = "localhost";

    try {//from   w w w. j  a  v a2  s.  co  m
        InetAddress theAddress = InetAddress.getByName(host);
        for (int i = 1024; i < 65536; i++) {
            Socket theSocket = new Socket(theAddress, i);
            System.out.println("There is a server on port " + i + " of " + host);
        }
    } catch (Exception ex) {
        System.err.println(ex);
    }

}

From source file:MainClass.java

public static void main(String[] args) {
    File aFile = new File("C:/test.bin");
    FileInputStream inFile = null;
    try {/*from w w w  . ja v  a  2s .c  o m*/
        inFile = new FileInputStream(aFile);
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
    }
    FileChannel inChannel = inFile.getChannel();
    final int PRIMECOUNT = 6;
    ByteBuffer buf = ByteBuffer.allocate(8 * PRIMECOUNT);
    long[] primes = new long[PRIMECOUNT];
    try {
        while (inChannel.read(buf) != -1) {
            ((ByteBuffer) (buf.flip())).asLongBuffer().get(primes);
            for (long prime : primes) {
                System.out.printf("%10d", prime);
            }
            buf.clear();
        }
        inFile.close();
    } catch (IOException e) {
        e.printStackTrace(System.err);
    }
}

From source file:DateUtilsV1.java

 public static void main(String args[]) {
   GregorianCalendar calendar = new GregorianCalendar(1974, 5, 25, 6, 30, 30);
   Date date = calendar.getTime();

   System.err.println("Original Date: " + date);
   System.err.println("Rounded Date: " + DateUtils.round(date, Calendar.HOUR));
   System.err.println("Truncated Date: " +   DateUtils.truncate(date, Calendar.MONTH));

   Iterator itr = DateUtils.iterator(date, DateUtils.RANGE_WEEK_MONDAY);

   while(itr.hasNext()) {
      System.err.println(((Calendar)itr.next()).getTime());
   }/* w  w  w  . jav a2s . c  om*/
}

From source file:Main.java

public static void main(String args[]) {
    try {// w  w w . j  av a 2  s  . c om
        MongoClient mongoClient = new MongoClient("localhost", 27017);

        DB db = mongoClient.getDB("test");
        System.out.println("Connect to database successfully");
        boolean auth = db.authenticate("myUser", "myPassword".toCharArray());
        System.out.println("Authentication: " + auth);
    } catch (Exception e) {
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
    }
}

From source file:MainClass.java

public static void main(String[] args) {
    File aFile = new File("file.dat");
    FileInputStream inFile = null;

    try {//from   w w  w  . ja  v a2  s .co  m
        inFile = new FileInputStream(aFile);
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
        System.exit(0);
    }
    FileChannel inChannel = inFile.getChannel();
    final int COUNT = 6;
    ByteBuffer buf = ByteBuffer.allocate(8 * COUNT);
    long[] data = new long[COUNT];
    try {
        while (inChannel.read(buf) != -1) {
            ((ByteBuffer) (buf.flip())).asLongBuffer().get(data);
            System.out.println();
            for (long prime : data)
                System.out.printf("%10d", prime);
            buf.clear();
        }
        System.out.println("\nEOF reached.");
        inFile.close();
    } catch (IOException e) {
        e.printStackTrace(System.err);
        System.exit(1);
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String dbURL = "jdbc:odbc:Companies";
    try {/* ww  w  .  ja v  a  2  s.c o  m*/
        // Load the jdbc-odbc bridge driver
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        // Enable logging
        DriverManager.setLogWriter(new PrintWriter((System.err)));

        System.out.println("Getting Connection");
        Connection conn = DriverManager.getConnection(dbURL, "user", "password");

        SQLWarning warn = conn.getWarnings();
        while (warn != null) {
            System.out.println("SQLState: " + warn.getSQLState());
            System.out.println("Message:  " + warn.getMessage());
            System.out.println("Vendor:   " + warn.getErrorCode());
            System.out.println("");
            warn = warn.getNextWarning();
        }

        conn.close();
    } catch (ClassNotFoundException e) {
        System.out.println("Can't load driver " + e);
    } catch (SQLException e) {
        System.out.println("Database access failed " + e);
    }
}

From source file:AddException.java

/** Main program */
public static void main(String[] argv) {
    int number = 0;

    System.out.println("The number of words in argv is " + argv.length);

    if (argv.length == 0) {
        number = 1234;/*from w  w w .j  a  v a  2  s .  c om*/
    } else if (argv.length == 1) {
        try {
            number = Integer.parseInt(argv[0]);
        } catch (NumberFormatException e) {
            System.err.println("Number " + argv[0] + " invalid (" + e.getMessage() + ").");
            System.exit(1);
        }
    } else {
        System.err.println("usage: UseArgv number");
        System.exit(1);
    }

    System.out.println("OK, number is " + number);
}

From source file:BasicDataSourceExample.java

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

    BasicDataSource bds = new BasicDataSource();
    bds.setDriverClassName("com.mysql.jdbc.Driver");
    bds.setUrl("jdbc:mysql://localhost/commons");
    bds.setUsername("root");
    bds.setPassword("");

    //      bds.setInitialSize(5);

    Connection connection = bds.getConnection();

    System.err.println(connection);
    connection.close();// www  .  j  a  va2 s. c  om
}