-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathemail_regex.java
More file actions
45 lines (35 loc) · 999 Bytes
/
email_regex.java
File metadata and controls
45 lines (35 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.ub.codeeval;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class email_regex {
private boolean validateMailId(String mailId) {
if(mailId.matches("(\\w+)[@](\\w+)\\.(\\w+)") == true )
return true;
else
return false;
}
public static void main(String[] args) {
email_regex email = new email_regex();
File file = new File(args[0]);
String line;
try {
BufferedReader br = new BufferedReader(new FileReader(file));
while( (line = br.readLine()) != null ) {
if (email.validateMailId(line) == true) {
System.out.println("true");
}else {
System.out.println("false");
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}