User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 456,528 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,781 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 643 | Replies: 5
Reply
Join Date: Jul 2007
Posts: 36
Reputation: abar_sow is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
abar_sow abar_sow is offline Offline
Light Poster

Paragraph

  #1  
Oct 3rd, 2007
can anyone explain wat this program is abt. ?

import java.util.regex.*;
import java.lang.*;
import java.io.*;
import java.util.*;

public class ReadPara
{

public static void main(String[] args)
{
CharSequence inputStr;
inputStr = "a\r\n\r\nb"; // Windows


// Compile the pattern
String patternStr = "(^.*\\S+.*$)+";
Pattern pattern = Pattern.compile(patternStr, Pattern.MULTILINE);
Matcher matcher = pattern.matcher(inputStr);

// Read the paragraphs
while (matcher.find()) {
// Get the paragraph
String paragraph = matcher.group();
}
}
}
Last edited by abar_sow : Oct 3rd, 2007 at 10:33 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Posts: 1,515
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is online now Online
Posting Virtuoso

Re: Paragraph

  #2  
Oct 3rd, 2007
Why don't you ask the person you copied it from?

Or did you write this yourself, and are having a problem, and so are really asking what's wrong with it? If that's the case why don't you tell what happens that you do not expect.

Also, read the API for the classes and methods used, and then you should be able to figure something out about. If you still are unsure, after that, come back, tell us what you think, and maybe we will help further. But my first point is the relevant one, I believe.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Jul 2007
Posts: 36
Reputation: abar_sow is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
abar_sow abar_sow is offline Offline
Light Poster

Re: Paragraph

  #3  
Oct 3rd, 2007
i got tat prog from one site while browsing..This is the explanation given in tat

This example demonstrates how to read paragraphs from a CharSequence. A paragraph is a contiguous sequence of non-blank lines separated by one or more blank lines. The lines in a paragraph can be terminated with any of the legal line termination character sequences: \r, \r\n, or \n.

my doubt is where we are giving input para ...??wats tat charsequence.If u understood from above explanation tel me
Reply With Quote  
Join Date: Dec 2006
Location: in a dream
Posts: 127
Reputation: nschessnerd is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 6
nschessnerd's Avatar
nschessnerd nschessnerd is offline Offline
Junior Poster

Re: Paragraph

  #4  
Oct 3rd, 2007
You would need to look at the other classes (like Pattern)
It prolly just goes through the code and finds escape characters (\n\t\r) ... you cant tell what it does unless you have the other files
Reply With Quote  
Join Date: Feb 2006
Posts: 1,515
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is online now Online
Posting Virtuoso

Re: Paragraph

  #5  
Oct 3rd, 2007
Originally Posted by nschessnerd View Post
You would need to look at the other classes (like Pattern)
It prolly just goes through the code and finds escape characters (\n\t\r) ... you cant tell what it does unless you have the other files


Pattern and Matcher are parts of the JRE. That's why I said to read the API doc for those classes and methods.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Feb 2006
Posts: 1,515
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is online now Online
Posting Virtuoso

Re: Paragraph

  #6  
Oct 3rd, 2007
Originally Posted by abar_sow View Post
i got tat prog from one site while browsing..This is the explanation given in tat

This example demonstrates how to read paragraphs from a CharSequence. A paragraph is a contiguous sequence of non-blank lines separated by one or more blank lines. The lines in a paragraph can be terminated with any of the legal line termination character sequences: \r, \r\n, or \n.

my doubt is where we are giving input para ...??wats tat charsequence.If u understood from above explanation tel me


"inputStr" is the "input paragraph". (as implied by the name)

It seems to be a simple pattern example/test. This should be self-explanatory if you read the API docs for Pattern and Matcher, as already suggested.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 4:19 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC