Hello , I am having trouble computing the frequencies of characters in a given i
ID: 3742343 • Letter: H
Question
Hello , I am having trouble computing the frequencies of characters in a given input file.(Ignoring all tabs, spaces and line returns)
I have to :
Input: a txt file (use argv[])
Output: a txt file (use argv[]) with the following format:
Char 1 # count (and so on for every other char)
This is on Huffman Coding if that helps.
Thankyou for any of your help in advance.
Explanation / Answer
import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class CharacterFrequencies { public static void main(String[] args) { if(args.length > 1) { String inputFilename = args[0]; String outputFilename = args[1]; try { Scanner fin = new Scanner(new File(inputFilename)); Map map = new HashMap(); String line; while (fin.hasNextLine()) { line = fin.nextLine(); for(int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.