I created a file that contains a text.
I want to read specific words like "end", "so", and "because" using Set
to store these keywords and using Map
to display all the keywords and the number of times repeated.
Can you show me how I should go about doing that?
...
openButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
int chosenFile = fileChooser.showOpenDialog(null);
if(chosenFile == JFileChooser.APPROVE_OPTION){
File selectedFile = fileChooser.getSelectedFile();
if ( selectedFile.canRead()){
Set<String> keywordList = new HashSet<String>();
keywordList.add("and");
keywordList.add("so");
keywordList.add("because”);
...
I don’t know how I could go from here to use Map
to fine the keyword.