-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
62 lines (45 loc) · 1.5 KB
/
Copy pathMain.java
File metadata and controls
62 lines (45 loc) · 1.5 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.io.*;
import java.util.Map;
public class Main {
public static void main(String[] args) throws IOException {
System.out.println("Hello World");
Employee e=new Employee();
e.newEmployee(101,"naseer",50000);
e.newEmployee(102,"chaitanya",50000);
e.newEmployee(103,"triraj",60000);
}
}
class Employee{
private String PATH = System.getProperty("user.dir");
public void newEmployee(int empid,String ename,int esal) {
PrintWriter pw = null;
try {
// pw = new PrintWriter(new File(PATH+"/employee.csv"));
String filepath=PATH+"/employee.csv";
RandomAccessFile rmfile=null;
rmfile = new RandomAccessFile(filepath,"rw");
rmfile.seek(rmfile.length());
System.out.println(rmfile.length());
System.out.println(rmfile.getFilePointer());
StringBuilder sb = new StringBuilder();
sb.append(empid);
sb.append(",");
sb.append(ename);
sb.append(",");
sb.append(esal);
sb.append('\n');
rmfile.writeBytes(String.valueOf(sb));
System.out.println(sb);
System.out.println("Length of rm file : " + rmfile.length());
}
catch (Exception e) {
e.printStackTrace();
}
//pw.write(sb.toString());
//pw.close();
}
public void displayEmployees(){
}
public void DelEmployee(int empid){
}
}