Split a line from a para in java

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-04-30T07:27:03Z Indexed on 2010/04/30 7:47 UTC
Read the original article Hit count: 470

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about split

Related posts about line