JSoup HTML Parse and Write Results to CSV In Order - java

I am trying to find the best approach to saving the data I have parsed out of the HTML document when Jsoup into a CSV. The problem I'm having is using [CSVWriter][1] - https://mvnrepository.com/artifact/com.opencsv/opencsv/4.6 and writing the data with it. Please see my code snippet below. The structure of the data looks like the following with infobox being the main listing record with each subsequent field within it. The CSVWriter looks like it is a String Array but having trouble going from elements to write to the CSVData writer with a String Array.
The Jsoup selector is returning an array of items from the selection. For instance, when I make the selection for the name, it is returning all 9 names if there are 9 records on the page. I need to put this data together in order for each row to print into a CSV.
InfoBox >
Name|
Email|
Phone|
Website
The problem I'm having is how I'm trying to write the data on this line below
writer.writeAll((Iterable<String[]>) infoArray);
This is not working correctly and errors but wanted to show what I am kind of after and if there is somebody who's familiar with writing data from Jsoup Elements into CSV. Thanks
String filePath ="c:/results.csv";
// first create file object for file placed at location
// specified by filepath
File file = new File(filePath);
try {
// create FileWriter object with file as parameter
FileWriter outputfile = new FileWriter(file);
// create CSVWriter object filewriter object as parameter
CSVWriter writer = new CSVWriter(outputfile);
String[] header = { "Name", "Phone", "Street","State","City","Zipcode" };
Elements infobox = doc.select(".info");
List<String> infoArray = new ArrayList<>();
for(int i = 0; i < infobox.size(); i++){
infobox.get(i).select(".business-name > span");
infoArray.add(infobox.get(i).select(".business-name > span").text());
infoArray.add(infobox.get(i).select(".phones.phone.primary").text());
infoArray.add(infobox.get(i).select(".street-address").text());
infoArray.add(infobox.get(i).select(".state").text());
infoArray.add(infobox.get(i).select(".city").text());
infoArray.add(infobox.get(i).select(".zip").text());
}
writer.writeNext(header);
//How to write data in order to match each record accordingly?
//Data should be written to CSV like the following example under each header into each corrosponding row
//name, phone, street
writer.writeAll((Iterable<String[]>) infoArray);
for(String ia : infoArray){
}
// closing writer connection
writer.close();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Here's what ended up working for me. The problem was not adding Strings into a String array to pass to CSVWriter. Here is my example.
try {
String[] header = { "Name", "Phone", "Street","State","City","Zipcode" };
Elements infobox = doc.select(".info");
if(count == 0){
writer.writeNext(header);
}
for(int i = 0; i < infobox.size(); i++){
infobox.get(i).select(".business-name > span");
String businessName = infobox.get(i).select(".business-name > span").text();
String phone = infobox.get(i).select(".phones.phone.primary").text();
String address = infobox.get(i).select(".street-address").text();
//Address seems to be displayed another way too
String address2 = infobox.get(i).select(".adr").text();
//Use regular expression to normalize data
String[] columns = new String[]{
businessName, phone, address
};
writer.writeNext(columns);
}
writer.close();
}

Here is little example how to use OpenCSV. Maybe will be helpful for you.
HeaderNames.java
public class HeaderNames
{
public static final String NAME = "Name";
public static final String PHONE = "Phone";
public static final String STREET = "Street";
public static final String STATE = "State";
public static final String CITY = "City";
public static final String ZIPCODE = "Zipcode";
}
DemoDTO.java
import java.io.Serializable;
import com.opencsv.bean.CsvBindByName;
public class DemoDTO implements Serializable
{
private static final long serialVersionUID = 1L;
#CsvBindByName(column = HeaderNames.NAME)
private String name;
#CsvBindByName(column = HeaderNames.PHONE)
private String phone;
#CsvBindByName(column = HeaderNames.STREET)
private String street;
#CsvBindByName(column = HeaderNames.STATE)
private String state;
#CsvBindByName(column = HeaderNames.CITY)
private String city;
#CsvBindByName(column = HeaderNames.ZIPCODE)
private String zipcode;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getPhone()
{
return phone;
}
public void setPhone(String phone)
{
this.phone = phone;
}
public String getStreet()
{
return street;
}
public void setStreet(String street)
{
this.street = street;
}
public String getState()
{
return state;
}
public void setState(String state)
{
this.state = state;
}
public String getCity()
{
return city;
}
public void setCity(String city)
{
this.city = city;
}
public String getZipcode()
{
return zipcode;
}
public void setZipcode(String zipcode)
{
this.zipcode = zipcode;
}
}
Main.java
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.opencsv.CSVWriter;
import com.opencsv.bean.HeaderColumnNameMappingStrategy;
import com.opencsv.bean.StatefulBeanToCsv;
import com.opencsv.bean.StatefulBeanToCsvBuilder;
import com.opencsv.exceptions.CsvDataTypeMismatchException;
import com.opencsv.exceptions.CsvRequiredFieldEmptyException;
public class Main
{
public static void main(String[] args) throws IOException, CsvDataTypeMismatchException, CsvRequiredFieldEmptyException
{
File file = new File(System.getProperty("user.dir") + System.getProperty("file.separator") + "results.csv");
FileWriter writer = new FileWriter(file);
List<DemoDTO> beans = new ArrayList<DemoDTO>();
for (int i = 0; i < 10; i++)
{
DemoDTO demoDTO = new DemoDTO();
demoDTO.setCity("city " + i);
demoDTO.setName("name " + i);
demoDTO.setPhone("phone " + i);
demoDTO.setState("state " + i);
demoDTO.setStreet("street " + i);
demoDTO.setZipcode("zipcode " + i);
beans.add(demoDTO);
}
HeaderColumnNameMappingStrategy<DemoDTO> strategy = new HeaderColumnNameMappingStrategy<>();
strategy.setType(DemoDTO.class);
StatefulBeanToCsv<DemoDTO> beanToCsv = new StatefulBeanToCsvBuilder<DemoDTO>(writer)
.withSeparator(';')
.withEscapechar(CSVWriter.NO_ESCAPE_CHARACTER)
.withLineEnd(CSVWriter.DEFAULT_LINE_END)
.withQuotechar(CSVWriter.DEFAULT_QUOTE_CHARACTER)
.withMappingStrategy(strategy)
.withThrowExceptions(true)
.build();
beanToCsv.write(beans);
writer.flush();
writer.close();
}
}

Related

Sorting a CSV file by district

Hello I wanna create a program that sorts the following csv file I'm trying to sort the file by their district. So the following program reads the file and is able to sort it but it sorts it by their name and I wanna change it so it sorts by district any help is appreciated.
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class SortDistrict
{
private static final String COLUMN_SEPARATOR = ",";
public static void main(String[] args) throws Exception
{
InputStream inputStream = new FileInputStream("data.csv");
List<List<String>> lines = readCsv(inputStream);
// Create a comparator that compares the elements from column 0,
// in ascending order
Comparator<List<String>> c0 = createAscendingComparator(0);
// Create a comparator that compares the elements from column 2,
// in descending order
Comparator<List<String>> c1 = createDesendingComparator(2);
// Create a comparator that compares primarily by using c0,
// and secondarily by using c1
Comparator<List<String>> comparator = createComparator(c0, c1);
Collections.sort(lines, comparator);
OutputStream outputStream = new FileOutputStream("output.csv");
String header = "Last Name, First Name, Email, Address, Age, District, Gender";
writeCsv(header, lines, outputStream);
}
private static List<List<String>> readCsv(
InputStream inputStream) throws IOException
{
BufferedReader reader = new BufferedReader(
new InputStreamReader(inputStream));
List<List<String>> lines = new ArrayList<>();
String line = null;
// Skip header
line = reader.readLine();
while (true)
{
line = reader.readLine();
if (line == null)
{
break;
}
List<String> list = Arrays.asList(line.split(COLUMN_SEPARATOR));
lines.add(list);
}
return lines;
}
private static void writeCsv(
String header, List<List<String>> lines, OutputStream outputStream)
throws IOException
{
Writer writer = new OutputStreamWriter(outputStream);
writer.write(header+"\n");
for (List<String> list : lines)
{
for (int i = 0; i < list.size(); i++)
{
writer.write(list.get(i));
if (i < list.size() - 1)
{
writer.write(COLUMN_SEPARATOR);
}
}
writer.write("\n");
}
writer.close();
}
#SafeVarargs
private static <T> Comparator<T>
createComparator(Comparator<? super T>... districts)
{
return (t0, t1) ->
{
for (Comparator<? super T> district : districts)
{
int n = district.compare(t0, t1);
if (n != 0)
{
return n;
}
}
return 0;
};
}
private static <T extends Comparable<? super T>> Comparator<List<T>>
createAscendingComparator(int index)
{
return createListAtIndexComparator(Comparator.naturalOrder(), index);
}
private static <T extends Comparable<? super T>> Comparator<List<T>>
createDesendingComparator(int index)
{
return createListAtIndexComparator(Comparator.reverseOrder(), index);
}
private static <T> Comparator<List<T>>
createListAtIndexComparator(Comparator<? super T> delegate, int index)
{
return (list0, list1) ->
delegate.compare(list0.get(index), list1.get(index));
}
}
I also have a Person class if it'll be any use
public class Person implements Comparable<Person> {
private String name;
private String email;
private String address;
private String residency;
private String gender;
private int age;
private int district;
public Person(String name, String email, String address, String gender, String residency, int district, int age) {
this.name = name;
this.address = address;
this.age = age;
this.district = district;
this.residency = residency;
this.gender = gender;
}
public String getName() {
return name;
}
public String getAddress() {
return address;
}
public int getAge() {
return age;
}
public String getResidency() {
return residency;
}
public int getDistrict() {
return district;
}
public String getGender() {
return gender;
}
public String toString() {
return (name + "," + email + "," + address + "," + age + "," + residency + "," + district + "," + gender);
}
public int compareTo(Person another) {
if (district == another.getDistrict())
return 0;
else if (district < another.getDistrict())
return -1;
else
return 1;
} // end of compareTo
} // end of Person
The csv file is quite big but here is a few lines
First Name, Last Name, Email, Address, Age, Residency, District, Gender
Colleen,Joyner,commodo.auctor#elementumat.net,Ap #697-1279 Nullam Road,30,Resident,4,Female
Fay,Parker,augue.ut.lacus#egetvarius.edu,"P.O. Box 234, 6576 Et, Ave",24,Resident,4,Female
TaShya,Atkinson,sem.egestas#urna.com,"6319 At, St.",45,Resident,15,Female
Curran,Shannon,massa#arcu.com,"980 In, Rd.",57,Resident,8,Male
Yolanda,Snyder,ipsum.ac#Sednullaante.org,"P.O. Box 769, 8207 Egestas Avenue",54,Non-Resident,4,Female
Candice,Weaver,ligula#Aenean.ca,"Ap #599-9287 Tellus, Rd.",35,Resident,9,Female
Yoshio,Silva,fames#Cumsociisnatoque.co.uk,Ap #327-6404 Dui St.,19,Resident,4,Male
Thanks in advance
You need to sort a large CSV file by a specific field and output result to another CSV file. The code will be complex and lengthy if you try to do this in Java.
Yet, with SPL, the open-source Java package, you only need one line of code:
A
1
>file("output.csv").export#ct(file("data.csv").cursor#cqt().sortx(District))
SPL offers JDBC driver to be invoked by Java. Just store the above SPL script as sort.splx and invoke it in Java as you call a stored procedure:
…
Class.forName("com.esproc.jdbc.InternalDriver");
con= DriverManager.getConnection("jdbc:esproc:local://");
st=con.prepareCall("call sortx()");
st.execute();
…
Or execute the SPL string within a Java program as we execute a SQL statement:
…
st = con.prepareStatement("=>file(\"output.csv\").export#ct(file(\"data.csv\").cursor#cqt().sortx(District))");
st.execute();
…

Loading and editing a CSV file in Java into a List

I'm working on a private project where i need to load a CSV file, keep it in the program and edit if needed.
The file looks like this:
ID;Name;Last Login;RevState;List
157;Guy;"01.11.19";false;"tag, cup, sting"
A60;Dud;"07.10.19";true;"ice, wood, cup, tag"
1D5;Wilfred;"11.11.19";true;"beer, food, cup, shower"
I will only ever have a single csv file loaded. I need to be able to edit every single data point. I need to be able to retrieve all the information of one "category", e.g. get all names.
So what I plan to do is load the CSV via
Scanner scanner = new Scanner(new File(file.csv))
Create a class that holds the information of a line
public class User
private String id;
private String name;
private String lastLogin;
private String list;
public getter and setter methods
Create a list
private List<User> csvList = new List<User>();
And then store every line as
while (file.hasNextLine())
[...] parse the line
User user = new User(id, name, lastLogin, list);
csvList.add(user);
Would this work, or is there a better method that I can't think of right now?
Here it goes:
public class User {
private int id;
private String name;
private String email;
private String phone;
public User() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
#Override
public String toString() {
return "User{" +
"id=" + id +
", name='" + name + '\'' +
", email='" + email + '\'' +
", phone='" + phone + '\'' +
'}';
}
}
Main class
import java.io.*;
import java.util.*;
public class Main {
public static void main(String [] args ) throws Exception {
List<User> users = new ArrayList<>();
String path = System.getProperty("user.dir");
FileInputStream fileInputStream = new FileInputStream(path+"/src/"+"users.csv");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream));
String line = "";
int lines = 0;
while((line=bufferedReader.readLine())!=null){
lines++;
String [] columns = line.split(",");
if(lines ==1 ) {
continue;
}
else {
User user = new User();
user.setId(Integer.parseInt(columns[0]));
user.setName(columns[1]);
user.setEmail(columns[2]);
user.setPhone(columns[3]);
users.add(user);
}
}
for(int i=0;i< users.size();i++){
System.out.println(users.get(i));
}
}
}
And users.csv file
Id, Name, Email, Phone
1, John, john.doe#gmail.com, 123456789

Java Isolate comma seperated values in text file

I've been searching for a solution to my problem without any luck. So now I'm asking here for help.
I'm creating "Groups" by the following class:
public class Group {
private String groupID;
private ArrayList<User> usersInGroup;
The User class looks like this:
NOTE: I already have an ArrayList containing all existing Users.
public class User {
private String firstName;
private String lastName;
private String age;
private String gender;
private String usernameID;
private String password;
I'm already adding the groupID field from the "groupData.txt" CSV text file like this:
public static ArrayList<Group> listOfCreatedGroups() throws IOException {
ArrayList<Group> listOfGroups = new ArrayList<>();
FileReader fr = new FileReader("src/groupData.txt");
BufferedReader bfr = new BufferedReader(fr);
String line;
int totalLine = Destination.linesInFile("src/groupData.txt"); //total lines in file
for (int i = 0; i < totalLine; i++) {
line = bfr.readLine();
String[] groupID = line.split(",");
Group temp = new Group();
temp.setGroupID(groupID[0]);
listOfGroups.add(temp);
}
try {
bfr.close();
fr.close();
} catch (IOException e) {
e.printStackTrace();
}
return listOfGroups;
}
The "groupData.txt" file is structured like this:
Line example = groupID,String_1,String2,String3 ... Stringn,\n
groupid,user,user,user,user,user,user,user,
groupid,user,user,user,
groupid,user,user,user,user,user
groupid,user,user
groupid,user,user,user,user
Since I only have the number of users in every group User.usernameID as 1 to n strings in the text file I can't add the whole User object to the Arraylist usersInGroup.
I somehow need to isolate the usernameID's and find the corresponding Users and add them to the ArrayList usersInGroup.
I hope any of you can give me a hint in the right direction. Thanks.
I don't know if this is how you were wanting because I didn't find the user data very specific or even mentioned of how you wanted. But let me know if this is enough
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
public class Group {
private static String groupID;
private static ArrayList<User> usersInGroup = new ArrayList<User>();
public static void main (String [] args) throws IOException {
addListToGroup(readFile());
}
public static void addListToGroup(ArrayList<ArrayList<String>> list) {
for (int i = 0; i < list.size(); i++) {
groupID = list.get(i).get(0);
for (int x = 0; x < list.get(i).size(); x++) {
User temp = new User(); // change this to however you setup the txt file
// the information from the list is in list.get(i).get(x) in order as in the textfile
temp.setAge(null);
temp.setFirstName(null);
temp.setGender(null);
temp.setLastName(null);
temp.setPassword(null);
temp.setUsernameID(null);
usersInGroup.add(temp);
}
}
}
public static ArrayList<ArrayList<String>> readFile() throws IOException {
List<String> temp = new ArrayList<String>();
Path path = Paths.get("file.txt");
temp = Files.readAllLines(path);
ArrayList<ArrayList<String>> lines = new ArrayList<ArrayList<String>>();
for (int i = 0; i < temp.size(); i++) {
String [] s = temp.get(i).split(",");
ArrayList<String> quickArray = new ArrayList<String>();
for (int x=0; x < s.length; x++) {
quickArray.add(s[x]);
}
lines.add(quickArray);
}
return lines;
}
}
class User {
private String firstName;
private String lastName;
private String age;
private String gender;
private String usernameID;
private String password;
//setters and getters
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getUsernameID() {
return usernameID;
}
public void setUsernameID(String usernameID) {
this.usernameID = usernameID;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

How to extract the row data-wise data with column constraint from a text file in java

I am developing java Swing based desktop application without using database (file based application). whenever i am trying to extract the specified row wise data, the constraints were not working as expected.
i am reading the entire text file line by line using scanner, but i am struggling to give the constraint for search functionality.
Could you please give me some suggestions on how to extract row wise data using column as a constraint..
e.g:
SL.No|Name|Salary
1|ABC|1000
2|DEF|2000
3|GHI|1500
note: this is my file structure, Could you please give me some suggestions on how to extract row wise data using column as a constraint..(like Name)
First create wrapper class for data
public class Data
{
private int serialNo;
private String name;
private double salary;
public int getSerialNo()
{
return this.serialNo;
}
public void setSerialNo(int serialNo)
{
this.serialNo = serialNo;
}
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name = name;
}
public double getSalary()
{
return this.salary;
}
public void setSalary(double salary)
{
this.salary = salary;
}
}
Create separate class for fetching data from file
public class Parser
{
private File file;
private BufferedReader bufferedReader;
public Parser(File file)
{
this.file = file;
}
public ArrayList<Data> parse() throws IOException
{
ArrayList<Data> dataList = new ArrayList<>();
bufferedReader = new BufferedReader(new FileReader(file));
//skip first line as it contains colums
bufferedReader.readLine();
String line = "";
while((line = bufferedReader.readLine()) !=null)
{
String[] tokens = line.split("\\|");
Data data = new Data();
data.setSerialNo(Integer.valueOf(tokens[0]));
data.setName(tokens[1]);
data.setSalary(Double.valueOf(tokens[2]));
dataList.add(data);
}
return dataList;
}
}
Finally Use like this
Parser parser = new Parser(new File("data.txt"));
ArrayList<Data> dataList = parser.parse();
for(Data data : dataList)
System.out.println("Ser="+ data.getSerialNo() + " Name=" + data.getName() + " Salary=" + data.getSalary());
Console output
Ser=1 Name=ABC Salary=1000.0
Ser=2 Name=DEF Salary=2000.0
Ser=3 Name=GHI Salary=1500.0

Reading contents of a file into class objects

I have a text file of employee entries as follows:
000, first name1, middle name1
001, first name2, middle name2
002, first name3, middle name3
003, first name4, middle name4
004, first name5, middle name5
And I have a class Employee as follows:
public class Employee {
public int id;
public String fName;
public String mName;
public String lName;
}
I've read the contents of the file into an array. But what I want is to construct an array of objects of class Employee, and a way for each attribute of the class to be initialised with each entry. Something like this:
Employee e[] = new Employee[5];
Checking the details of each object in the array...
e[0].id = 000
e[0].fName = "first name1"
e[0].mName = "middle name1"
e[0].lName = "last name1"
Then,
e[1].id = 001
And so on...
Is there any way I can do this?
public class Employee {
public int id;
public String fName;
public String mName;
public String lName;
public Employee(String line) {
String[] split = line.split(",");
id = Integer.parseInt(split[0]);
fName = split[1];
mName = split[2];
lName = split[3];
}
}
Since you already read the file into array (of string I suppose).
String[] lines = ....;
Employee[] employees = new Employee[lines.length];
for(int i = 0; i < lines.length; i++) {
employees[i] = new Employee(lines[i]);
}
There you go... you have an array of employees.
Read the file and loop over its content line by line. Then parse the lines and create a new Employee() in each iteration. Set your values, such as id and name. Finally, add your new Employee instance to a List<Employee> and continue with the next entry.
// Read data from file
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
// List to collect Employee objects
List<Employee> employees = new ArrayList<Employee>();
// Read file line by line
String line = "";
while ((line = br.readLine()) != null) {
// Parse line to extract individual fields
String[] data = this.parseLine(line);
// Create new Employee object
Employee employee = new Employee();
employee.id = Integer.valueOf(data[0]);
employee.fName = data[1];
employee.mName = data[2];
// Add object to list
employees.add(employee);
}
// Further process your Employee objects...
}
Also, there are CSV libraries that can handle all the nasty parts of reading a file that has comma separated values. I'd suggest using OpenCSV, for example.
Here already answers posted but I still gonna post mine...
package com.stackoverflow.java.test;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class Employee {
public int id;
public String fName;
public String mName;
public Employee(int id, String fName, String mName) {
this.id = id;
this.fName = fName;
this.mName = mName;
}
public static void main(String[] args) throws IOException {
Employee[] e = new Employee[5];
FileReader fr=new FileReader("YourDoc.txt");
BufferedReader br=new BufferedReader(fr);
String line="";
String[] arrs=null;
int num=0;
while ((line=br.readLine())!=null) {
arrs=line.split(",");
e[num] = new Employee(Integer.valueOf(arrs[0]), arrs[1], arrs[2]);
num++;
}
br.close();
fr.close();
for(int i=0 ; i< e.length; i++) {
System.out.println(e[i].id + " and " + e[i].fName + " and " + e[i].mName);
}
}
}
try :
public static void main(String[] args) throws IOException {
File f1 = new File("d:\\data.txt");
Scanner scanner = new Scanner(f1);
List<Employee1> empList=new ArrayList<>();
while(scanner.hasNextLine()){
String data[]=scanner.nextLine().split(",");
empList.add(new Employee(Integer.parseInt(data[0]),data[1],data[2],data[3]));
}
scanner.close();
System.out.println(empList);
}
Employee.java
class Employee{
public int id;
public String fName;
public String mName;
public String lName;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getfName() {
return fName;
}
public void setfName(String fName) {
this.fName = fName;
}
public String getmName() {
return mName;
}
public void setmName(String mName) {
this.mName = mName;
}
public String getlName() {
return lName;
}
public void setlName(String lName) {
this.lName = lName;
}
public Employee(int id, String fName, String mName, String lName) {
super();
this.id = id;
this.fName = fName;
this.mName = mName;
this.lName = lName;
}
#Override
public String toString() {
return "Employee [id=" + id + ", fName=" + fName + ", mName="
+ mName + ", lName=" + lName + "]";
}
}

Categories

Resources