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

public static void main(String args[]) {

    System.err.println(StringUtils.deleteWhitespace("f f f f"));
}

From source file:StringUtilsExampleV1.java

public static void main(String args[]) {
    System.err.println(StringUtils.center("MTV", 7, '='));
}

From source file:Run2.java

public static void main(String[] args) throws java.io.IOException {
    if (args.length != 1) {
        System.err.println("usage: java Run pathname");
        return;//from   w w  w  . j a  va2 s .c om
    }

    Process p = Runtime.getRuntime().exec(args[0]);

    InputStream is = p.getInputStream();
    int b;
    while ((b = is.read()) != -1)
        System.out.print((char) b);

    try {
        System.out.println("Exit status = " + p.waitFor());
    } catch (InterruptedException e) {
    }
}

From source file:PrintFile.java

public static void main(String args[]) throws Exception {
    if (args.length != 2) {
        System.err.println("usage : java PrintFile port file");
        System.err.println("sample: java PrintFile LPT1 sample.prn");
        System.exit(-1);//from  w w w .j av  a 2s.  c  om
    }

    String portname = args[0];
    String filename = args[1];

    // Get port
    CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portname);

    // Open port
    // Requires owner name and timeout
    CommPort port = portId.open("Java Printing", 30000);

    // Setup reading from file
    FileInputStream fis = new FileInputStream(filename);
    BufferedInputStream bis = new BufferedInputStream(fis);

    // Setup output
    OutputStream os = port.getOutputStream();
    BufferedOutputStream bos = new BufferedOutputStream(os);

    int c;
    while ((c = bis.read()) != -1) {
        bos.write(c);
    }

    // Close
    bos.close();
    bis.close();
    port.close();
}

From source file:Main.java

public static void main(String[] args) {
    try {//from www . j a v  a 2  s .c  o m
        throwWarning();
    } catch (SQLException e) {
        System.err.println("An SQL exception occurred: " + e);
        e.printStackTrace();
        while ((e = e.getNextException()) != null) {
            System.err.println("Contained reason: " + e);
        }
    }
}

From source file:Main.java

public static void main(String[] args) throws ClassNotFoundException, SQLException {
    Console console = System.console();
    if (console == null) {
        System.err.println("sales: unable to obtain console");
        return;/*from w w  w.ja  va2s.c  o  m*/
    }

    String username = console.readLine("Enter username: ");
    System.out.println(username);
}

From source file:MailExample.java

public static void main(String args[]) throws Exception {
    if (args.length != 3) {
        System.err.println("Usage: java MailExample host from to");
        System.exit(-1);/* w ww.ja v a 2 s  . c  o  m*/
    }

    String host = args[0];
    String from = args[1];
    String to = args[2];

    // Get system properties
    Properties props = System.getProperties();

    // Setup mail server
    props.put("mail.smtp.host", host);

    // Get session
    Session session = Session.getDefaultInstance(props, null);

    // Define message
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
    message.setSubject("The Subject");
    message.setText("The Message");

    // Send message
    Transport.send(message);
}

From source file:MainClass.java

public static void main(String[] args) throws ClassNotFoundException, SQLException {
    Console console = System.console();
    if (console == null) {
        System.err.println("sales: unable to obtain console");
        return;//  w w  w.j  av a2 s.c om
    }

    console.printf("%s ", "string");
}

From source file:MainClass.java

public static void main(String[] args) throws ClassNotFoundException, SQLException {
    Console console = System.console();
    if (console == null) {
        System.err.println("sales: unable to obtain console");
        return;// w ww .j a  va  2s  .com
    }

    String password = new String(console.readPassword("Enter password: "));
    System.out.println(password);
}

From source file:DigestUsage.java

public static void main(String args[]) {
    DigestUsage codec = new DigestUsage();
    try {/*  ww  w .j a v  a2s  .  c om*/
        codec.start();
    } catch (Exception e) {
        System.err.println(e);
    }
}