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

public static void main(String args[]) {
    Transformer transformer = TransformerUtils.invokerTransformer("append", new Class[] { String.class },
            new Object[] { " a Transformer?" });
    Object newObject = transformer.transform(new StringBuffer("Are you"));
    System.err.println(newObject);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    ResourceBundle resources;/*w w w . j av a 2s . c  o m*/

    try {
        resources = ResourceBundle.getBundle("MyData");
        System.out.println(resources.getString("Hi"));
    } catch (MissingResourceException e) {
        e.printStackTrace();
        System.err.println("MyData.properties not found");
    }
}

From source file:FractionExampleV1.java

public static void main(String args[]) {
    Fraction twoThirds = Fraction.TWO_THIRDS;
    Fraction fraction_whole = Fraction.getFraction(2, 2, 3);
    Fraction fraction = Fraction.getFraction(27, 98);
    Fraction fraction_double = Fraction.getFraction(4.56);
    Fraction fraction_string = Fraction.getFraction("2 1/3");

    System.err.println(twoThirds.doubleValue());
    System.err.println(fraction_string.getNumerator());
    System.err.println(fraction_whole.divideBy(fraction_double));
    System.err.println(fraction.divideBy(fraction));
}

From source file:MainClass.java

public static void main(String[] args) {
    int[] array = new int[] { 1, 0, 2 };
    int index = 0;
    try {//from   w  w  w.j  a  v  a  2 s  .c o m
        System.out.println("\nFirst try block in divide() entered");
        array[index + 2] = array[index] / array[index + 1];
        System.out.println("Code at end of first try block in divide()");
    } catch (ArithmeticException e) {
        System.err.println("Arithmetic exception caught in divide()\n" + "\nMessage in exception object:\n\t"
                + e.getMessage());
        System.err.println("\nStack trace output:\n");
        e.printStackTrace();
        System.err.println("\nEnd of stack trace output\n");
    } catch (ArrayIndexOutOfBoundsException e) {
        System.err.println("Index-out-of-bounds exception caught in divide()\n"
                + "\nMessage in exception object:\n\t" + e.getMessage());
        System.err.println("\nStack trace output:\n");
        e.printStackTrace();
        System.out.println("\nEnd of stack trace output\n");
    } finally {
        System.err.println("finally clause in divide()");
    }
    System.out.println("Executing code after try block in divide()");
}

From source file:Main.java

public static void main(String[] ap) {
    String line = null;/*from   w w  w . j  a v a 2s. c  o  m*/
    int val = 0;
    try {
        BufferedReader is = new BufferedReader(new InputStreamReader(System.in));
        line = is.readLine();
        val = Integer.parseInt(line);
    } catch (NumberFormatException ex) {
        System.err.println("Not a valid number: " + line);
    } catch (IOException e) {
        System.err.println("Unexpected IO ERROR: " + e);
    }
    System.out.println("I read this number: " + val);
}

From source file:MainClass.java

public static void main(String args[]) {
    try {/*from ww  w.  j a  v  a  2  s.  c o m*/
        URL u = new URL("http://www.java2s.com");
        URLConnection uc = u.openConnection();
        System.out.println("Content-encoding: " + uc.getContentEncoding());
    } catch (MalformedURLException e) {
        System.err.println("not a URL I understand");
    } catch (IOException e) {
        System.err.println(e);
    }
}

From source file:BeanUtilsExampleV5.java

  public static void main(String args[]) throws Exception {
    BeanUtilsExampleV5 diff = new BeanUtilsExampleV5();
    Movie movie = diff.prepareData();/*from   ww w  .  j  a  v  a 2 s  .c o  m*/

    System.err.println(
       LocaleBeanUtils.getProperty(movie, "dateOfRelease", "dd-MMM-yyyy"));

}

From source file:MainClass.java

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

    try {//from  www  .j  av  a2  s. com
        DataInputStream in3 = new DataInputStream(new ByteArrayInputStream("a dbcde".getBytes()));
        while (true)
            System.out.print((char) in3.readByte());
    } catch (EOFException e) {
        System.err.println("End of stream");
    }

}

From source file:MainClass.java

public static void main(String[] args) {

    String host = "localhost";

    for (int i = 1; i < 1024; i++) {
        try {//w  ww  .  ja  va2s  .co  m
            Socket s = new Socket(host, i);
            System.out.println("There is a server on port " + i + " of " + host);
        } catch (UnknownHostException ex) {
            System.err.println(ex);
            break;
        } catch (IOException ex) {
        }
    }
}

From source file:MainClass.java

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

    InputStream in = null;//ww  w.jav a 2  s. c  om
    try {
        URL u = new URL("http://www.java2s.com");
        in = u.openStream();
        for (int c = in.read(); c != -1; c = in.read()) {
            System.out.write(c);
        }
        in.close();
    } catch (MalformedURLException ex) {
        System.err.println("not a URL Java understands.");
    } finally {
        if (in != null)
            in.close();
    }
}