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

public static void main(String[] args) throws Exception {
    AsynchronousFileChannel fileChannel = AsynchronousFileChannel.open(Paths.get("/asynchronous.txt"),
            StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.CREATE);
    CompletionHandler<Integer, Object> handler = new CompletionHandler<Integer, Object>() {

        @Override/*from ww  w.  j  a v a  2 s.c o  m*/
        public void completed(Integer result, Object attachment) {
            System.out.println("Attachment: " + attachment + " " + result + " bytes written");
            System.out.println("CompletionHandler Thread ID: " + Thread.currentThread().getId());
        }

        @Override
        public void failed(Throwable e, Object attachment) {
            System.err.println("Attachment: " + attachment + " failed with:");
            e.printStackTrace();
        }
    };

    System.out.println("Main Thread ID: " + Thread.currentThread().getId());
    fileChannel.write(ByteBuffer.wrap("Sample".getBytes()), 0, "First Write", handler);
    fileChannel.write(ByteBuffer.wrap("Box".getBytes()), 0, "Second Write", handler);

}

From source file:SettingPageSizeLEGALNOTE.java

public static void main(String[] args) {
    Document document = new Document();
    try {//www.j  a  v  a  2  s . c o  m
        PdfWriter.getInstance(document, new FileOutputStream("SettingPageSizeLEGALNOTE.pdf"));
        document.open();
        document.add(new Paragraph("First Page."));
        document.setPageSize(PageSize.LEGAL);
        document.newPage();
        document.add(new Paragraph("This PageSize is LEGAL."));

        document.setPageSize(PageSize.NOTE);
        document.newPage();
        document.add(new Paragraph("This PageSize is NOTE."));

    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    try {// w ww.j  a  v a 2  s .co m
        Connection conn = getHSQLConnection();

        conn.setAutoCommit(false);
        Statement st = conn.createStatement();
        st.executeUpdate("create table survey (id int,name varchar(30));");
        st.executeUpdate("insert into survey (id,name ) values (1,'nameValue')");
        st = conn.createStatement();
        ResultSet rs = st.executeQuery("SELECT * FROM survey");

        outputResultSet(rs);

        rs.close();
        st.close();
        conn.close();
    } catch (SQLException sqle) {
        do { // loop through each exception
             // do something with each exception
            System.err.println("Exception occurred:\nMessage: " + sqle.getMessage());
            System.err.println("SQL state: " + sqle.getSQLState());
            System.err.println("Vendor code: " + sqle.getErrorCode() + "\n----------------");
        } while ((sqle = sqle.getNextException()) != null);
    }
}

From source file:AddingMorethanOneChunkPDF.java

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

        Chunk test = new Chunk("some text");
        float subscript = -8.0f;
        test.setTextRise(subscript);
        test.setUnderline(new Color(0xFF, 0x00, 0x00), 3.0f, 0.0f, -5.0f + subscript, 0.0f,
                PdfContentByte.LINE_CAP_ROUND);
        document.add(test);

        Chunk test1 = new Chunk("another text");

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

From source file:SpringInAction4Edition.MainApp.java

public static void main(String[] args) {

    ApplicationContext context = new AnnotationConfigApplicationContext(CDConfig.class);

    Environment env = context.getEnvironment();
    System.err.println("environment : ime : " + env.getProperty("ime"));
    System.err.println("environment : prezime : " + env.getProperty("prezime"));

    KutijaCD cd_ovi = context.getBean(KutijaCD.class);
    CDPlayer cDPlayer = context.getBean(CDPlayer.class);

    cd_ovi.getCds().stream().forEach((cd) -> {
        cd.play();// w  w  w. j  a va  2 s  . c  om
    });

    cDPlayer.getCd();
    System.err.println("BEAN DEF NAMES : " + Arrays.toString(context.getBeanDefinitionNames()));
}

From source file:DOMCheck.java

static public void main(String[] arg) {
    boolean validate = true;

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setValidating(validate);/*from w  w w . ja v a 2  s. c o m*/
    dbf.setNamespaceAware(true);

    try {
        DocumentBuilder builder = dbf.newDocumentBuilder();
        builder.setErrorHandler(new MyErrorHandler());
        InputSource is = new InputSource("person.xml");
        Document doc = builder.parse(is);
    } catch (SAXException e) {
        System.out.println(e);
    } catch (ParserConfigurationException e) {
        System.err.println(e);
    } catch (IOException e) {
        System.err.println(e);
    }
}

From source file:finger.java

public static void main(String[] args) {

    String hostname;//from  w  ww .  jav  a 2s. c  om
    Socket theSocket;
    DataInputStream theFingerStream;
    PrintStream ps;

    try {
        hostname = args[0];
    } catch (Exception e) {
        hostname = "localhost";
    }

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

}

From source file:MultipleLinedTextPDF.java

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

        Chunk chunk;
        chunk = new Chunk("Multiple lines");
        chunk.setUnderline(new Color(0xFF, 0x00, 0x00), 0.0f, 0.3f, 0.0f, 0.4f, PdfContentByte.LINE_CAP_ROUND);
        chunk.setUnderline(new Color(0x00, 0xFF, 0x00), 3.0f, 0.0f, 0.0f, -0.5f,
                PdfContentByte.LINE_CAP_PROJECTING_SQUARE);
        chunk.setUnderline(new Color(0x00, 0x00, 0xFF), 0.0f, 0.2f, 15.0f, 0.0f, PdfContentByte.LINE_CAP_BUTT);
        document.add(chunk);

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

From source file:DBCPDemo.java

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

    // create a generic pool
    GenericObjectPool pool = new GenericObjectPool(null);

    // use the connection factory which will wraped by
    // the PoolableConnectionFactory
    DriverManagerConnectionFactory cf = new DriverManagerConnectionFactory(
            "jdbc:jtds:sqlserver://myserver:1433/tandem", "user", "pass");

    PoolableConnectionFactory pcf = new PoolableConnectionFactory(cf, pool, null, "SELECT * FROM mysql.db",
            false, true);// w ww  . j  a  v a 2s. com

    // register our pool and give it a name
    new PoolingDriver().registerPool("myPool", pool);

    // get a connection and test it
    Connection conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:myPool");

    // now we can use this pool the way we want.
    System.err.println("Are we connected? " + !conn.isClosed());

    System.err.println("Idle Connections: " + pool.getNumIdle() + ", out of " + pool.getNumActive());

}

From source file:Main.java

public static void main(String[] a) throws Exception {
    if (SystemTray.isSupported()) {
        SystemTray tray = SystemTray.getSystemTray();

        trayIcon.setImageAutoSize(true);
        trayIcon.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.out.println("In here");
                trayIcon.displayMessage("Tester!", "Some action performed", TrayIcon.MessageType.INFO);
            }//w w  w  . ja  v a2s  .  c om
        });

        try {
            tray.add(trayIcon);
        } catch (AWTException e) {
            System.err.println("TrayIcon could not be added.");
        }
    }
}