summaryrefslogtreecommitdiff
path: root/java/countWords.java
diff options
context:
space:
mode:
authorpants <niklasjo2004@gmail.com>2026-09-21 14:17:03 -0700
committerpants <niklasjo2004@gmail.com>2026-09-21 14:17:03 -0700
commit7b21727285e50b0b050c4ddd70d07542229c5366 (patch)
tree5d369153c5df5b41f3750d25479a68f20169c8ff /java/countWords.java
init
Diffstat (limited to 'java/countWords.java')
-rwxr-xr-xjava/countWords.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/java/countWords.java b/java/countWords.java
new file mode 100755
index 0000000..cd8ce98
--- /dev/null
+++ b/java/countWords.java
@@ -0,0 +1,14 @@
+import java.io.*;
+import java.util.*;
+
+public class countWords {
+ public static void main(String[] args) throws FileNotFoundException {
+ Scanner fileScanner = new Scanner(new File(args[0]));
+ int count = 0;
+ while (fileScanner.hasNext()) {
+ count++;
+ String dummy = fileScanner.next();
+ }
+ System.out.println(count);
+ }
+}