Source Code : Data file
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Data file

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class DataFileTest {
static void writeData(Employee e, PrintWriter out) throws IOException {
e.writeData(out);
}
static Employee readData(BufferedReader in) throws IOException {
Employee e = new Employee();
e.readData(in);
return e;
}
public static void main(String[] args) {
Employee staff = new Employee("Java Source", 35500);
staff.raiseSalary(5.25);
try {
PrintWriter out = new PrintWriter(new FileWriter("employee.dat"));
writeData(staff, out);
out.close();
} catch (IOException e) {
System.out.print("Error: " + e);
System.exit(1);
}
try {
BufferedReader in = new BufferedReader(new FileReader(
"employee.dat"));
Employee e = readData(in);
e.print();
in.close();
} catch (IOException e) {
System.out.print("Error: " + e);
System.exit(1);
}
}
}
class Employee {
private String name;
private double salary;
public Employee(String n, double s) {
name = n;
salary = s;
}
public Employee() {
}
public void print() {
System.out.println(name + " " + salary );
}
public void raiseSalary(double byPercent) {
salary *= 1 + byPercent / 100;
}
public void writeData(PrintWriter out) throws IOException {
out.println(name + "|" + salary);
}
public void readData(BufferedReader in) throws IOException {
String s = in.readLine();
StringTokenizer t = new StringTokenizer(s, "|");
name = t.nextToken();
salary = Double.parseDouble(t.nextToken());
}
}
Thank with us