Validar E-mail corporativo

Java

25/11/2011

Bom dia a Todos.

Tenho um cadastro de fornecedores e neste cadastro existe o campo email,
preciso validar esse email,

atualmente valido apenas a forma estrutura verificando se no mesmo existe @, .com ou .br,

porém não sei com validar sua existencia.

Preciso saber se os senhores sabem ou tem algo facilite essa validação.

Deste já agradeço a ajuda.

Atenciosamente,
R. Barcelos
Barcelos.java

Barcelos.java

Curtidas 0

Respostas

Dyego Carmo

Dyego Carmo

25/11/2011

use uma expressao regular :)


    try {  
                FileReader reader = new FileReader(new File(meusEmails.txt));  
                BufferedReader leitor = new BufferedReader(reader);  
      
      
                String emails = leitor.readLine(); //Se estiver tudo em uma linha...  
      
                //Expressao regular para detectar email  
                String patternEmail = [_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3});  
                Pattern padrao = Pattern.compile(patternEmail);  
                Matcher matcher = padrao.matcher(linha);  
      
                while(matcher.find()) {  
                    MatchResult matchResult = matcher.toMatchResult();  
                    System.out.println(matchResult.group());  
                }  
            } catch(Exception e) {  
                e.printStackTrace();  
            }  
GOSTEI 0
Dyego Carmo

Dyego Carmo

25/11/2011

use uma expressao regular :)


    try {  
                FileReader reader = new FileReader(new File(meusEmails.txt));  
                BufferedReader leitor = new BufferedReader(reader);  
      
      
                String emails = leitor.readLine(); //Se estiver tudo em uma linha...  
      
                //Expressao regular para detectar email  
                String patternEmail = [_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3});  
                Pattern padrao = Pattern.compile(patternEmail);  
                Matcher matcher = padrao.matcher(linha);  
      
                while(matcher.find()) {  
                    MatchResult matchResult = matcher.toMatchResult();  
                    System.out.println(matchResult.group());  
                }  
            } catch(Exception e) {  
                e.printStackTrace();  
            }  
GOSTEI 0
POSTAR