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

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

   GenericKeyedObjectPool pool = new GenericKeyedObjectPool();
   pool.setFactory(new SkilledEmployeeFactory());

   pool.addObject("Java");
   pool.addObject("Java");
   pool.addObject("VB");
   pool.addObject("C++");

   System.err.println("Number of Java employees in pool: " +
     pool.getNumIdle("Java") + " out of total employees: " +
     pool.getNumIdle());//ww w  .j  a v a  2  s . c o  m

   Employee employee = (Employee)pool.borrowObject("Java");

   employee.doWork();

   System.err.println("Employee: "  + employee);

   pool.returnObject("Java", employee);

   System.err.println("Number of Java employees in pool: " +
     pool.getNumIdle("Java") + " out of total employees: " +
     pool.getNumIdle());
}

From source file:MainClass.java

public static void main(String[] args) {
    File aFile = new File("primes.txt");
    FileInputStream inFile = null;
    try {/*from  ww  w.  j a  v a 2  s .c om*/
        inFile = new FileInputStream(aFile);
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
    }
    FileChannel inChannel = inFile.getChannel();
    try {
        ByteBuffer lengthBuf = ByteBuffer.allocate(8);
        while (true) {
            if (inChannel.read(lengthBuf) == -1) {
                break;
            }
            lengthBuf.flip();
            int strLength = (int) lengthBuf.getDouble();
            ByteBuffer buf = ByteBuffer.allocate(2 * strLength + 8);
            if (inChannel.read(buf) == -1) {
                break;
            }
            buf.flip();
            byte[] strChars = new byte[2 * strLength];
            buf.get(strChars);
            System.out.println(strLength);
            System.out.println(ByteBuffer.wrap(strChars).asCharBuffer());
            System.out.println(buf.getLong());
            lengthBuf.clear();
        }
        inFile.close();
    } catch (IOException e) {
        e.printStackTrace(System.err);
    }
}

From source file:MainClass.java

public static void main(String[] args) {
    URL u;//from  w  w  w.j a v a2  s  .  com
    URLConnection uc;
    try {
        u = new URL("http://www.java2s.com");
        try {
            uc = u.openConnection();
            if (uc.getUseCaches()) {
                uc.setUseCaches(false);
            }
        } catch (IOException e) {
            System.err.println(e);
        }
    } catch (MalformedURLException e) {
        System.err.println(e);
    }

}

From source file:MainClass.java

public static void main(String[] args) {
    try {//w  ww. j  av  a  2s. c  o  m
        MyHttpHandler handler = new MyHttpHandler();
        URLConnection uc = handler.openConnection(new URL("http://www.ora.com"));
        if (!uc.getAllowUserInteraction()) {
            uc.setAllowUserInteraction(true);
        }
    } catch (MalformedURLException e) {
        System.err.println(e);
    } catch (IOException e) {
        System.err.println(e);
    }

}

From source file:Main.java

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

    long time = System.currentTimeMillis();
    FileTime fileTime = FileTime.fromMillis(time);
    Path path = Paths.get("C:/tutorial/Java/JavaFX", "Topic.txt");

    try {/* ww  w  .j  av a2 s.c o m*/
        Files.setLastModifiedTime(path, fileTime);
    } catch (IOException e) {
        System.err.println(e);
    }

}

From source file:ActiveTray.java

public static void main(String args[]) throws Exception {
    if (SystemTray.isSupported() == false) {
        System.err.println("No system tray available");
        return;/*from   w  w  w .  j a v  a 2s  .c o m*/
    }
    final SystemTray tray = SystemTray.getSystemTray();
    PropertyChangeListener propListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            TrayIcon oldTray[] = (TrayIcon[]) evt.getOldValue();
            TrayIcon newTray[] = (TrayIcon[]) evt.getNewValue();
            System.out.println(oldTray.length + " / " + newTray.length);
        }
    };
    tray.addPropertyChangeListener("trayIcons", propListener);
    Image image = Toolkit.getDefaultToolkit().getImage("jpgIcon.jpg");
    PopupMenu popup = new PopupMenu();
    MenuItem item = new MenuItem("Hello, World");
    final TrayIcon trayIcon = new TrayIcon(image, "Tip Text", popup);
    ActionListener menuActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            trayIcon.displayMessage("Good-bye", "Cruel World", TrayIcon.MessageType.WARNING);
        }
    };
    item.addActionListener(menuActionListener);
    popup.add(item);
    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            tray.remove(trayIcon);
        }
    };
    trayIcon.addActionListener(actionListener);
    tray.add(trayIcon);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new FileReader("ravi.txt"));
    while (true) {
        String line = br.readLine();
        if (line == null)
            break;
        if (!UCODE_PATTERN.matcher(line).matches()) {
            System.err.println("Bad input: " + line);
        } else {//www  .  jav a 2s .co m
            String hex = line.substring(2, 6);
            int number = Integer.parseInt(hex, 16);
            System.out.println(hex + " -> " + ((char) number));
        }
    }
}

From source file:SimpleXMLTransform.java

static public void main(String[] arg) {
    if (arg.length != 3) {
        System.err.println("Usage: SimpleXMLTransform " + "<input.xml> <input.xsl> <output>");
        System.exit(1);// www.  j  a v a2 s .com
    }
    String inXML = arg[0];
    String inXSL = arg[1];
    String outTXT = arg[2];

    SimpleXMLTransform st = new SimpleXMLTransform();
    try {
        st.transform(inXML, inXSL, outTXT);
    } catch (TransformerConfigurationException e) {
        System.err.println("Invalid factory configuration");
        System.err.println(e);
    } catch (TransformerException e) {
        System.err.println("Error during transformation");
        System.err.println(e);
    }
}

From source file:URLGet.java

public static void main(String[] args) {
    BufferedReader in = null;/*from  w  w w  .jav a2s.  c o m*/
    if (args.length == 1) {
        try {
            URL url = new URL(args[0]);
            in = new BufferedReader(new InputStreamReader(url.openStream()));
            String line = null;
            while ((line = in.readLine()) != null)
                System.out.println(line);
        } catch (MalformedURLException ex) {
            System.err.println(ex);
        } catch (FileNotFoundException ex) {
            System.err.println("Failed to open stream to URL: " + ex);
        } catch (IOException ex) {
            System.err.println("Error reading URL content: " + ex);
        }
        if (in != null)
            try {
                in.close();
            } catch (IOException ex) {
            }
    } else
        System.err.println("Usage: URLGet URL");
}

From source file:Main.java

public static void main(String[] args) {
    Path ball_path = Paths.get("C:/tutorial/photos", "ball.png");
    byte[] ball_bytes = new byte[] { (byte) 0x89, (byte) 0x50, (byte) 0x4e, };

    try {//from ww w . jav a2 s. c  o m
        Files.write(ball_path, ball_bytes);
    } catch (IOException e) {
        System.err.println(e);
    }
}