lundi 31 juillet 2017

How to print a specific word in a text file in Java

so as you can see i have a text file that goes like this one:

unbelievable, un, believe, able
mistreatment, mis, treat, ment
understandable, understand, able

I need to get the morphemes or each word like for example if I typed in the word MISTREATMENT, the output would be MIS, TREAT, MENT and the root word is TREAT.

Here's my code so far:

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

public class morph {

    public static void main(String[] args) throws IOException {

         System.out.println("Enter a word: ");
         Scanner sc = new Scanner (System.in);
         sc.nextLine();

         BufferedReader br = new BufferedReader(new FileReader("C:/Users/xxxx/Desktop/morphemes.txt"));
         String line = null;
         while ((line = br.readLine()) != null) {

             //i'm stuck

             System.out.println("The morpheme words are: "); // EG: mis , treat, ment
             System.out.println("The Root word is: "); // EG: treat
         }
    }
}

Please help me a newbie

Aucun commentaire:

Enregistrer un commentaire