Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.util.Map;
- import java.util.Scanner;
- import java.util.TreeMap;
- import java.util.regex.Pattern;
- public class Main {
- public static void main(String[] args) {
- Scanner in = null;
- try {
- in = new Scanner(new File(args[0]));
- }
- catch (Exception e) {
- }
- Map<Integer, Integer> map = new TreeMap<Integer, Integer>();
- Pattern p = Pattern.compile("\\d");
- while (in.hasNext(p)) {
- int i = 0;
- try {
- i = new Integer(in.next(p));
- }
- catch (Exception e) {
- }
- if (map.get(i) == null) map.put(i, 0);
- else map.put(i, map.get(i) + 1);
- }
- System.out.println(map);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement