Hello, I can't upload a text file. So, Here is textFileTwo.txt
------------------------------------------------------------------------------------------------ Closed captioning and subtitling are both processes of displaying text on a television, video screen, or other visual display to provide additional or interpretive information. Both are typically used as a transcription of the audio portion of a program as it occurs, sometimes including descriptions of non-speech elements. Other uses have been to provide a textual alternative language translation of a presentation's primary audio language that is usually burned-in to the video and unselectable. HTML5 defines subtitles as a transcription or translation of the dialogue, when sound is available but not understood by the viewer. And defines captions as a transcription or translation of the dialogue, sound effects, relevant musical cues, and other relevant audio information, when sound is unavailable or not clearly audible, for example, when audio is muted or the viewer is deaf or hard of hearing.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Create a new Java project with a class named FileInformation that reads a text file named “textFileTwo.txt”.
Your project should print out the following information about the file:
For example the number of words in “Hi, I love Java” is 4.
Here is the answer...
CODE:
import java.io.*;
class Stats {
public static void main(String[] args) {
BufferedReader file;
try {
file = new
BufferedReader(new FileReader("textFileTwo.txt"));
String s =
file.readLine();
int
word_count=0,comma_count=0;
while (s !=
null) {
word_count++;
for(int i=0;i<s.length();i++){
if(s.charAt(i)==' ')
{
word_count++;
//
System.out.println(i);
}
if(s.charAt(i)==',')
comma_count++;
}
s = file.readLine();
}
System.out.println("Word count = "+word_count);
System.out.println("Comma count = "+comma_count);
file.close();
} catch (IOException e) {
System.out.println("fike not found ");
}
}
}
OUTPUT:
textFileTwo.txt
Hi, I love Java
deaf
If you have any doubts please COMMENT...
If you understand the answer please give THUMBS UP...
Hello, I can't upload a text file. So, Here is textFileTwo.txt ------------------------------------------------------------------------------------------------ Closed captioning and subtitling...