Split a line from a para in java
- by John
Hi... I am having problem splitting a para into line.... i need to first read a file then split in into lines if i get a . or ! or ?
I also need to remove any extra white space...
This is wad i've written so far....
try {
Scanner line = new Scanner(mFile);
mLine = line.nextLine();
String Matrix[]=mLine.split("\\.");
for (int i = 0; i < Matrix.length; ++i)
{
System.out.println(Matrix[i]);
}
Input:
Hi. My name is John. Who are you ?
Output:
Hi
My name is John
Who are you