Question
/** * Opens and reads the contents of the dictionary file specified in fileName. The file is * assumed to be a text file encoded
/**
* Opens and reads the contents of the dictionary file specified in fileName. The file is
* assumed to be a text file encoded in UTF-8. It is assumed that there is one translation
* mapping per line. Each line contains a key and its translation separated by a tab.
* Note: The dictionary file is assumed to be sorted by the keys in ascending order.
*
* For each line in the dictionary file, an entry is added into wordList. The entry is a String
* array of length 2, where the value of index 0 is the key and the value of index 1 is the
* translation.
*
* When opening the file, any FileNotFoundException is caught and the error message
* "Exception: File 'fileName' not found." followed by a new line is output,
* where fileName is the name of the file that the method attempted to open.
*
* @param fileName
* @param wordList Reference to ArrayList to contain the translation mappings.
* @throws IOException if an I/O error occurs when closing the file. FileNotFoundException is
* caught when opening the file.
*/
public static void readDictFile(String fileName,
ArrayList
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