Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am using IntelliJ on Windows. The text file are to big to upload on chegg, I j

ID: 3872008 • Letter: I

Question

I am using IntelliJ on Windows.

The text file are to big to upload on chegg, I just need help on how to do it. The two files are:

Romans.txt

Hebrews.txt

Thanks.

Here is a little bit of the top of one of the files, so you can see the layout. (Romans1) [1 Paul, a servant of Jesus Christ, called to be an apostle, separated unto the gospel of God, [3] Concerning his Son Jesus Christ our Lord, which was made of the seed of David according to the flesh; [4] And declared to be the Son of God with power, according to the spirit of holiness, by the resurrection from the dead:

Explanation / Answer

import java.io.File;

import java.io.PrintWriter;

import java.util.Scanner;

public class ReadFile {

public static void main(String[] args) {

Scanner scannerKey = null, scannerFile = null;

;

try {

scannerKey = new Scanner(System.in);

String[] lineArr = new String[100];

int lineCount = 0, versesCount = 0;

System.out.print("Enter the file you wish to analyze: ");

String fileName = scannerKey.next();

File file = new File(fileName);

scannerFile = new Scanner(file);

for (int i = 0; i < lineArr.length && scannerFile.hasNext(); i++) {

String line = scannerFile.nextLine();

lineArr[i] = line;

lineCount++;

if (line.contains("verses"))

versesCount++;

}

System.out.println("There are " + lineCount + " lines");

System.out.println("There are " + versesCount + " verses");

System.out.print("Enter the word that you want search for: ");

String searchWord = scannerKey.next();

String newFile = file.getName().split("\.")[0] + "_" + searchWord

+ ".txt";

PrintWriter writer = new PrintWriter(new File(newFile));

int searchWordCount = 0;

for (int i = 0; i < lineCount; i++) {

String line = lineArr[i];

if (line.contains(searchWord)) {

searchWordCount++;

writer.write(line + " ");

}

}

writer.flush();

writer.close();

System.out.println("The word " + searchWord + " occurs "

+ searchWordCount + " times int file " + fileName);

System.out.println("Verses written out to file " + newFile);

scannerFile.close();

scannerKey.close();

} catch (Exception e) {

// TODO: handle exception

e.printStackTrace();

}

}

}

OUTPUT:

Enter the file you wish to analyze: Romans.txt
There are 4 lines
There are 0 verses
Enter the word that you want search for: God
The word God occurs 2 times int file Romans.txt
Verses written out to file Romans_God.txt

Romans.txt

Paul servant of jesus christ, called to be an apolite, seperated unto the gospel of God,
(Which he had promised afore by his prophets in the holy scriptures,)
Concerning his son jesus christ our lord, which has made of the seed of David according to the flesh.
And declared to be son of God with power, according to the spirit of holiness, by the resurrection from the bed:

Romans_God.txt

Paul servant of jesus christ, called to be an apolite, seperated unto the gospel of God,
And declared to be son of God with power, according to the spirit of holiness, by the resurrection from the bed:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote