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();
}
}
}

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.

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

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

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.

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.

This article has been dead for over six months. Start a new discussion instead.