•
•
•
•
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
![]() |
•
•
Join Date: Jul 2007
Posts: 36
Reputation:
Rep Power: 2
Solved Threads: 0
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.
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.
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
----------------------------------------------
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
•
•
Join Date: Jul 2007
Posts: 36
Reputation:
Rep Power: 2
Solved Threads: 0
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
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
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
----------------------------------------------
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
•
•
•
•
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
----------------------------------------------
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Removing paragraph (Java)
- Help with indenting infile -> outfile paragraph... (C++)
- Java vs Java3D (Java)
Other Threads in the Java Forum
- Previous Thread: confused about paintocomponent
- Next Thread: problem with tomcat server



Linear Mode