Results 1 to 2 of 2
  1. #1
    kcananda is offline Member
    Join Date
    Aug 2012
    Posts
    2
    Rep Power
    0

    Question splitting paragraph

    Hello everyone,

    Being a beginner to JAVA, I am trying to find out a solution for splitting paragraphs in a file, into lines of statements.

    Eg:- Paragraph in the given text file "sample" is
    "Welcome to programming in JAVA. Java was developed by James Gosling. It is an object oriented language. "

    The desired output is
    Welcome to programming in JAVA
    Java was developed by James Gosling
    Java is an object oriented language

    Can anyone help me out to find the way of achieving this.

  2. #2
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default Re: splitting paragraph

    Oh, what you might want to do is parse the text file and dump it's contents into a String variable. Then use something like the replace function in java.lang.String. Check out: String (Java Platform SE 6). The text you might want to replace would be the '. ' (a period and a whitespace) with a '\n' (newline character). Then you can use System.out.println(); to print out the contents of the String and see if it look like your desired output.

    Hope this helps.
    My API:
    Java Code:
    cat > a.out || cat > main.class

Similar Threads

  1. Replies: 3
    Last Post: 06-03-2011, 03:57 PM
  2. Replies: 2
    Last Post: 11-11-2009, 06:56 AM
  3. confusion in paragraph
    By JavaJunkie in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-19-2009, 04:02 PM
  4. Splitting paragraph into line statements
    By mintu in forum New To Java
    Replies: 3
    Last Post: 02-28-2009, 09:41 AM
  5. How to obtain Paragraph Layout
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-25-2008, 11:36 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •