public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); InputStream is = null; byte[] buffer = new byte[100]; int c; ArrayList<Integer> array = new ArrayList<Integer>(); try { // new input stream created is = new FileInputStream(reader.readLine()); is.read(buffer); for(byte b : buffer) { if(b == 0 ){ c = ' '; } else { c = (int)b; array.add(c); } Collections.sort(array); for(Integer result : array) { if(result!=0 && result%2 == 0) { System.out.println(result); } } } } catch(Exception e) { // if any I/O error occurs e.printStackTrace(); } finally { // releases system resources associated with this stream if(is!=null) is.close(); reader.close(); } } }