import java.util.regex.*;
class regexSample
{
public static void main(String args[])
{
//Input the string for validation
String email = "xyz@hotmail.com";
//Set the email pattern string
Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
//Match the given string with the pattern
Matcher m = p.matcher(email);
//check whether match is found
boolean matchFound = m.matches();
if (matchFound)
System.out.println("Valid Email Id.");
else
System.out.println("Invalid Email Id.");
}
}
Hi Folks, This is our blog where in we can post our questions n solutions related to java and share our experience in java programinng.so that we can master in the java.
JAVA N WEB TECH SYLLABUS
Wednesday, October 27, 2010
Email Address Validation Using a Regular Expression
The following code demonstrates how to validate email using regular expression:
Tuesday, October 26, 2010
Member Functions Of Character class
static boolean | isJavaIdentifierPart(char ch) Determines if the specified character may be part of a Java identifier as other than the first character. |
static boolean | isJavaIdentifierStart(char ch) Determines if the specified character is permissible as the first character in a Java identifier. |
static boolean | isJavaLetter(char ch) Deprecated. Replaced by isJavaIdentifierStart(char). |
static boolean | isJavaLetterOrDigit(char ch) Deprecated. Replaced by isJavaIdentifierPart(char). |
static boolean | isLetter(char ch) Determines if the specified character is a letter. |
static boolean | isLetterOrDigit(char ch) Determines if the specified character is a letter or digit. |
static boolean | isLowerCase(char ch) Determines if the specified character is a lowercase character. |
|
Sunday, October 24, 2010
Monday, October 11, 2010
Java Code For Finding the Substring
public static void main(String[] args) { String searchMe = "Look for a substring in me"; String substring = "sub"; System.out.println(searchMe.contains
(substring) ? "Found it" : "Didn't find it"); }
Member Functions Of String Buffer Class
| Method Summary | |
StringBuffer | append(boolean b) Appends the string representation of the boolean argument to the string buffer. |
StringBuffer | append(char c) Appends the string representation of the char argument to this string buffer. |
StringBuffer | append(char[] str) Appends the string representation of the char array argument to this string buffer. |
StringBuffer | append(char[] str, int offset, int len) Appends the string representation of a subarray of the char array argument to this string buffer. |
StringBuffer | append(double d) Appends the string representation of the double argument to this string buffer. |
StringBuffer | append(float f) Appends the string representation of the float argument to this string buffer. |
StringBuffer | append(int i) Appends the string representation of the int argument to this string buffer. |
StringBuffer | append(long l) Appends the string representation of the long argument to this string buffer. |
StringBuffer | append(Object obj) Appends the string representation of the Object argument to this string buffer. |
StringBuffer | append(String str) Appends the string to this string buffer. |
StringBuffer | append(StringBuffer sb) Appends the specified StringBuffer to this StringBuffer. |
int | capacity() Returns the current capacity of the String buffer. |
char | charAt(int index) The specified character of the sequence currently represented by the string buffer, as indicated by the index argument, is returned. |
StringBuffer | delete(int start, int end) Removes the characters in a substring of this StringBuffer. |
StringBuffer | deleteCharAt(int index) Removes the character at the specified position in this StringBuffer (shortening the StringBuffer by one character). |
void | ensureCapacity(int minimumCapacity) Ensures that the capacity of the buffer is at least equal to the specified minimum. |
void | getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) Characters are copied from this string buffer into the destination character array dst. |
int | indexOf(String str) Returns the index within this string of the first occurrence of the specified substring. |
int | indexOf(String str, int fromIndex) Returns the index within this string of the first occurrence of the specified substring, starting at the specified index. |
StringBuffer | insert(int offset, boolean b) Inserts the string representation of the boolean argument into this string buffer. |
StringBuffer | insert(int offset, char c) Inserts the string representation of the char argument into this string buffer. |
StringBuffer | insert(int offset, char[] str) Inserts the string representation of the char array argument into this string buffer. |
StringBuffer | insert(int index, char[] str, int offset, int len) Inserts the string representation of a subarray of the str array argument into this string buffer. |
StringBuffer | insert(int offset, double d) Inserts the string representation of the double argument into this string buffer. |
StringBuffer | insert(int offset, float f) Inserts the string representation of the float argument into this string buffer. |
StringBuffer | insert(int offset, int i) Inserts the string representation of the second int argument into this string buffer. |
StringBuffer | insert(int offset, long l) Inserts the string representation of the long argument into this string buffer. |
StringBuffer | insert(int offset, Object obj) Inserts the string representation of the Object argument into this string buffer. |
StringBuffer | insert(int offset, String str) Inserts the string into this string buffer. |
int | lastIndexOf(String str) Returns the index within this string of the rightmost occurrence of the specified substring. |
int | lastIndexOf(String str, int fromIndex) Returns the index within this string of the last occurrence of the specified substring. |
int | length() Returns the length (character count) of this string buffer. |
StringBuffer | replace(int start, int end, String str) Replaces the characters in a substring of this StringBuffer with characters in the specified String. |
StringBuffer | reverse() The character sequence contained in this string buffer is replaced by the reverse of the sequence. |
void | setCharAt(int index, char ch) The character at the specified index of this string buffer is set to ch. |
void | setLength(int newLength) Sets the length of this String buffer. |
CharSequence | subSequence(int start, int end) Returns a new character sequence that is a subsequence of this sequence. |
String | substring(int start) Returns a new String that contains a subsequence of characters currently contained in this StringBuffer.The substring begins at the specified index and extends to the end of the StringBuffer. |
String | substring(int start, int end) Returns a new String that contains a subsequence of characters currently contained in this StringBuffer. |
String | toString() Converts to a string representing the data in this string buffer. |
Member Functions Of String Class
| Method Summary | |
char | charAt(int index) Returns the character at the specified index. |
int | compareTo(Object o) Compares this String to another Object. |
int | compareTo(String anotherString) Compares two strings lexicographically. |
int | compareToIgnoreCase(String str) Compares two strings lexicographically, ignoring case differences. |
String | concat(String str) Concatenates the specified string to the end of this string. |
boolean | contentEquals(StringBuffer sb) Returns true if and only if this String represents the same sequence of characters as the specified StringBuffer. |
static String | copyValueOf(char[] data) Returns a String that represents the character sequence in the array specified. |
static String | copyValueOf(char[] data, int offset, int count) Returns a String that represents the character sequence in the array specified. |
boolean | endsWith(String suffix) Tests if this string ends with the specified suffix. |
boolean | equals(Object anObject) Compares this string to the specified object. |
boolean | equalsIgnoreCase(String anotherString) Compares this String to another String, ignoring case considerations. |
byte[] | getBytes() Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array. |
void | getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) Deprecated. This method does not properly convert characters into bytes. As of JDK 1.1, the preferred way to do this is via the the getBytes() method, which uses the platform's default charset. |
byte[] | getBytes(String charsetName) Encodes this String into a sequence of bytes using the named charset, storing the result into a new byte array. |
void | getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) Copies characters from this string into the destination character array. |
int | hashCode() Returns a hash code for this string. |
int | indexOf(int ch) Returns the index within this string of the first occurrence of the specified character. |
int | indexOf(int ch, int fromIndex) Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index. |
int | indexOf(String str) Returns the index within this string of the first occurrence of the specified substring. |
int | indexOf(String str, int fromIndex) Returns the index within this string of the first occurrence of the specified substring, starting at the specified index. |
String | intern() Returns a canonical representation for the string object. |
int | lastIndexOf(int ch) Returns the index within this string of the last occurrence of the specified character. |
int | lastIndexOf(int ch, int fromIndex) Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index. |
int | lastIndexOf(String str) Returns the index within this string of the rightmost occurrence of the specified substring. |
int | lastIndexOf(String str, int fromIndex) Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index. |
int | length() Returns the length of this string. |
boolean | matches(String regex) Tells whether or not this string matches the given regular expression. |
boolean | regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) Tests if two string regions are equal. |
boolean | regionMatches(int toffset, String other, int ooffset, int len) Tests if two string regions are equal. |
String | replace(char oldChar, char newChar) Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar. |
String | replaceAll(String regex, String replacement) Replaces each substring of this string that matches the given regular expression with the given replacement. |
String | replaceFirst(String regex, String replacement) Replaces the first substring of this string that matches the given regular expression with the given replacement. |
String[] | split(String regex) Splits this string around matches of the given regular expression. |
String[] | split(String regex, int limit) Splits this string around matches of the given regular expression. |
boolean | startsWith(String prefix) Tests if this string starts with the specified prefix. |
boolean | startsWith(String prefix, int toffset) Tests if this string starts with the specified prefix beginning a specified index. |
CharSequence | subSequence(int beginIndex, int endIndex) Returns a new character sequence that is a subsequence of this sequence. |
String | substring(int beginIndex) Returns a new string that is a substring of this string. |
String | substring(int beginIndex, int endIndex) Returns a new string that is a substring of this string. |
char[] | toCharArray() Converts this string to a new character array. |
String | toLowerCase() Converts all of the characters in this String to lower case using the rules of the default locale. |
String | toLowerCase(Locale locale) Converts all of the characters in this String to lower case using the rules of the given Locale. |
String | toString() This object (which is already a string!) is itself returned. |
String | toUpperCase() Converts all of the characters in this String to upper case using the rules of the default locale. |
String | toUpperCase(Locale locale) Converts all of the characters in this String to upper case using the rules of the given Locale. |
String | trim() Returns a copy of the string, with leading and trailing whitespace omitted. |
static String | valueOf(boolean b) Returns the string representation of the boolean argument. |
static String | valueOf(char c) Returns the string representation of the char argument. |
static String | valueOf(char[] data) Returns the string representation of the char array argument. |
static String | valueOf(char[] data, int offset, int count) Returns the string representation of a specific subarray of the char array argument. |
static String | valueOf(double d) Returns the string representation of the double argument. |
static String | valueOf(float f) Returns the string representation of the float argument. |
static String | valueOf(int i) Returns the string representation of the int argument. |
static String | valueOf(long l) Returns the string representation of the long argument. |
static String | valueOf(Object obj) Returns the string representation of the Object argument. |
Asymmetric Biometric Security System
Client- to – Client File Transfer in encrypted format using biometric fingerprint security.
Biometric recognition offers a reliable solution to the problem of user authentication in identity management systems. With the widespread deployment of biometric systems in various applications, there are increasing concerns about the security and privacy of biometric technology.
Here we are implementing a biometric security system where the files are transferred for a particular user using his finger print for authentication purpose. The Thinning algorithm is used for generating a unique key for each user. A thinning scheme could be used as a useful method of pre-processing in image processing.
Thursday, October 7, 2010
Simple JAVA
The basic structure of a Java program is as follows:
class ClassName {
}The class name must be the same as the file name, for example.
For our program, we will call it Tut1. We will call the file name Tut1.java so the structure will be:
You will notice that there are brackets after the method name. You can place variable names within these brackets which will receive the values passed to the method. I will talk more about this at a later stage.The most common method that you will use is the ‘main’ method. The class that is actually executed must have this method in the class. However not every class must have a ‘main’ method. The structure of the mainmethod is as follows:
public static void main(String args[])
{
}
Note the capital ‘S’ for String. This is important or you will receive an error.I believe that there are many different ways of outputting text. I will use one method which uses the standardjava package.
System.out.println("Welcome To My First Java Program ");
Again in this example, note the capital ‘S’ for System.
This code basically prints a line of text which is contained within the quotes. The line is terminated, like most lines in java, with a semi colon.
If we put all this code together, it will look like this:
class Tut1 {
public static void main(String args[])
{
System.out.println("Welcome To My First Java Program");
}
}
This program will output the following on the screen:Welcome To My First Java Program
Tuesday, October 5, 2010
Welcome to JAVA
Hi Folks,
This is our blog where in we can post our questions n solutions related to java and share our experience in java programinng.so that we can master in the java.
This is our blog where in we can post our questions n solutions related to java and share our experience in java programinng.so that we can master in the java.
Subscribe to:
Comments (Atom)