-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserDataReader.java
More file actions
28 lines (26 loc) · 913 Bytes
/
Copy pathUserDataReader.java
File metadata and controls
28 lines (26 loc) · 913 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
package spring.filehandling;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;
public class UserDataReader {
public UserBean getData() throws FileNotFoundException {
FileReader reader = new FileReader("C:/Users/JAWAHAR/wiley/JDBC/src/spring/filehandling/user_data.xml");
Scanner sc = new Scanner(reader);
UserBean myBean = new UserBean();
String s;
while ((s = sc.nextLine()) != null) {
if (s.trim().equals("<first_name>")) {
myBean.setFirst_name(sc.nextLine().trim());
break;
}
}
while ((s = sc.nextLine()) != null) {
if (s.trim().equals("<last_name>")) {
myBean.setLast_name(sc.nextLine().trim());
break;
}
}
sc.close();
return myBean;
}
}