I'm preparing an automation script which can check spelling mistakes from a website and show me the misspelled words and prepare a list for the same. To do this, I need to split sentences to the individual words so that my script can check spellings.
I'm opening URL's sequentially from a CSV file and copy-pasting all the content of each URL to a separate text file. Then I read that newly created text file and try to separate all the words into individual strings. Once I have the file with one word on each line, it will be fed to my spell check script.
For example, suppose a website has the content "Hello World". My code will create a new text file named 1.txt
which will contain the text "Hello World". From that I'm trying to read the text file and create a new file named 1_word_by_word.txt
which contains "Hello" in the 1st line and "World" in the 2nd.
Somehow I'm printing only the last word of the sentence. But when I send it to the console it's printing properly.
My code is:
while(scan.hasNextLine())
{
System.out.println(scan.next());
String word_by_word = scan.next();
String TestFile_2 = "Word_By_Word.txt";
File FC_2 = new File(TestFile_2);
FC_2.createNewFile();
//Create Object of java FileWriter and BufferedWriter class.
//Writing In to file.
FileWriter FileWriter_2 = new FileWriter(TestFile_2);
FileWriter_2.write(word_by_word);
FileWriter_2.flush();
FileWriter_2.close();
}