File: spellcheck.java

package info (click to toggle)
groovy2 2.2.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 23,916 kB
  • sloc: java: 136,570; xml: 948; sh: 486; makefile: 67; ansic: 64
file content (36 lines) | stat: -rw-r--r-- 1,063 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// $Id: spellcheck.java,v 1.1 2004-05-23 07:14:28 bfulgham Exp $
// http://www.bagley.org/~doug/shootout/

import java.io.*;
import java.util.*;

public class spellcheck {
    public static void main(String args[]) throws IOException {
        int n = Integer.parseInt(args[0]);
        HashMap dict = new HashMap();
        String word;

        try {
            BufferedReader in = new BufferedReader(new FileReader("Usr.Dict.Words"));
            while ((word = in.readLine()) != null) {
                dict.put(word, new Integer(1));
            }
            in.close();
        } catch (IOException e) {
            System.err.println(e);
            return;
        }

        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            while ((word = in.readLine()) != null) {
                if (!dict.containsKey(word)) {
                    System.out.println(word);
                }
            }
        } catch (IOException e) {
            System.err.println(e);
            return;
        }
    }
}