/** Class losning2* By Rune Vikestad* E-Mail vikestad@stud.ntnu.no* Web http://folk.ntnu.no/vikestad/* Description IT-1103, Basic Programming (Java), Exercise 6*/import java.io.*;import java.util.*;import javax.swing.JOptionPane;/*** Class: 'FileOp'*/public class losning2 { /** * Method: 'main'. */ public static void main(String[] args) throws IOException { /* * Variable Declarations */ String fileInName; // The name of the file we read int charCode; // The decimal value of a character read FileReader fr; // char wordPart; // String wordTemp = ""; String wordComplete = ""; int counter = 0; /* * Variable Initiations */ fileInName = JOptionPane.showInputDialog("File name: "); fr = new FileReader(fileInName); /* * Process our stream. */ do { charCode = fr.read(); if (charCode >= 65 && charCode < 97) { /* Found an upper case character, so make it lower case. */ charCode = charCode + 32; } if (charCode == 46) { /* Found a period ".". Replace with an Horizontal Tab.. Dirty hack, i know! */ charCode = 9; } else if (charCode == 44) { /* Found a comma ",". Replace with an Horizontal Tab.. Dirty hack, i know! */ charCode = 9; } wordPart = (char)charCode; wordTemp = wordTemp + wordPart; if (charCode == 32) { /* We found a SPACE, which means we found a word. Yay! */ counter = counter+1; System.out.println(wordTemp); wordTemp = ""; } } while (charCode > 0); if (charCode == 0) { System.out.println(wordTemp); } fr.close(); }}