|
|
|
1000 Java Tips ebook
|
|
 

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java
programming articles and tips. Please take your copy here.
Take your copy of free "Java Technology Screensaver"!. |
|
Easy Learn Java: Programming Articles, Examples and Tips - Page 381
Previous
1060 Stories (530 Pages, 2 Per Page)
Next
comma separated into string array
|
Question: How can I get substrings from comma separated string?
Example: Comma separated into string array operation can be done like this
private String[] commaSeparatedStringToStringArray(String
aString){
String[] splittArray = null;
if (aString != null ||
!aString.equalsIgnoreCase("")){
splittArray =
aString.split(",");
System.out.println(aString +
" " + splittArray);
}
return splittArray;
}
Then easily you find array size and loop it to get elements separately
comments? | | Score: 0
|
Posted by Anonymous on Thursday, July 07, 2005 (00:00:00) (30219 reads)
|
validate an IP address
|
Question: How can I validate an IP Address with help of regular expressions in my Java
code?
Answer: Look at this example below.
//Usage of regular expression in Java to validate an IP address
| Code: |
private boolean
validateAnIpAddressWithRegularExpression(String iPaddress){
final Pattern IP_PATTERN =
Pattern.compile("b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).)"
+ "{3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)b");
return IP_PATTERN.matcher(iPaddress).matches();
}
|
comments? | | Score: 4.77
|
Posted by Anonymous on Wednesday, July 06, 2005 (00:00:00) (37721 reads)
|
|
|