package FileHandling;
public class Candidate {
private int experience;
private String name;
private String primarySkill;
private String qualification;
public int getExperience() {
return experience;
}
public void setExperience(int experience) {
this.experience = experience;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPrimarySkill() {
return primarySkill;
}
public void setPrimarySkill(String primarySkill) {
this.primarySkill = primarySkill;
}
public String getQualification() {
return qualification;
}
public void setQualification(String qualification) {
this.qualification = qualification;
}
public String toString() {
return "Candidate [name=" + name + ", primarySkill=" + primarySkill+ ",experience=" + experience + ", qualification=" + qualification+ "]";
}
}
public class Candidate {
private int experience;
private String name;
private String primarySkill;
private String qualification;
public int getExperience() {
return experience;
}
public void setExperience(int experience) {
this.experience = experience;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPrimarySkill() {
return primarySkill;
}
public void setPrimarySkill(String primarySkill) {
this.primarySkill = primarySkill;
}
public String getQualification() {
return qualification;
}
public void setQualification(String qualification) {
this.qualification = qualification;
}
public String toString() {
return "Candidate [name=" + name + ", primarySkill=" + primarySkill+ ",experience=" + experience + ", qualification=" + qualification+ "]";
}
}
package FileHandling;
import java.io.*;
public class FileToObjectDemo {
public static Candidate createObjectFromFile(Reader re) throws IOException
{
FileReader red=(FileReader)re;
Candidate cd=new Candidate();
int ch;
while((ch=red.read())!=-1)
{
System.out.print((char)ch);
}
red.close();
return cd;
}
public static void main(String[] args) throws IOException {
Reader read=new FileReader("abhishek.txt");
createObjectFromFile(read);
}
}
0 comments:
Post a Comment