diff options
Diffstat (limited to 'wordcount.java')
| -rw-r--r-- | wordcount.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/wordcount.java b/wordcount.java new file mode 100644 index 0000000..8aba15d --- /dev/null +++ b/wordcount.java @@ -0,0 +1,18 @@ +import java.util.*; +import java.io.*; + +public class wordcount { + public static void main(String[] args) throws FileNotFoundException { + File input = new File(args[0]); + Scanner fileScanner = new Scanner(input); + + int count = 0; + while (fileScanner.hasNext()) { + String nextToken = fileScanner.next(); + count++; + } + + fileScanner.close(); + System.out.println(count); + } +} |
