Question
[JAVA] Please find error. This isn't working. ---------------------------------------------------------------------------------------------- import java.io.*; import java.util.*; public class CountWordsFile { @SuppressWarnings(resource) public static void main(String[] args){ String javaprogramming =
[JAVA]
Please find error. This isn't working.
----------------------------------------------------------------------------------------------
import java.io.*;
import java.util.*;
public class CountWordsFile {
@SuppressWarnings("resource")
public static void main(String[] args){
String javaprogramming = args[0];
TreeMap
try{
Scanner input = new Scanner(new File("testing.txt"));
while (input.hasNext()){
String line=input.nextLine();
String[]words=line.split("[ @!~{}\\[\\]$#^&* \t .,;?'\")(] "); for (int i=0;i if (words[i].trim().length () >0 && words[i].trim().matches("[A-Z|a-z]+")){ String key =words[i].toLowerCase(); if (TreeMap.get(key)!=null){ int count =TreeMap.get(key); count++; TreeMap.put(key,count); } else{ TreeMap.put(key, 1); } } } } } catch (Exception ex){ ex.printStackTrace(); } Set System.out.print(" Total words in the file:"); for (Map.Entry } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started