Java Code to find email ids in a string

Code to find email ids in a string using Pattern. 

String text="vivek boy goy sdjs@adjk";
Pattern regex = Pattern.compile("[@]");
Matcher regexMatcher = regex.matcher(text);
int i =0;
int width = 0;
while (regexMatcher.find()) {
     if((regexMatcher.start()-10 > 0) && (regexMatcher.end()+10 < text.length())){
       String[]    substr=text.substring(regexMatcher.start()-width,regexMatcher.end()+width).split(" ");
           for(int j=0;j<substr.length;j++){
                   if(substr[j].contains("@") && (substr[j].contains(".com") ||    substr[j].contains(".net"))){
               } else {

Related Post

Web crawler to get emails and images

Subscribe to Java News and Posts. Get latest updates and posts on Java from
Enter your email address:
Delivered by FeedBurner
comments powered by Disqus