Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package shit;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.io.Serializable;
- import java.util.Date;
- import java.util.Vector;
- public class Task implements Serializable{
- private String client;
- private String user;
- private String description;
- private Date issue_start;
- private String status;
- private Date issue_end;
- public Task (String client, String user, String description, Date issue_start, String status, Date issue_end) {
- this.client = client;
- this.user = user;
- this.description = description;
- this.status = status;
- this.issue_start = issue_start;
- this.issue_end = issue_end;
- this.status = status;
- }
- public static final String file = "C:\\Users\\Hawk\\Downloads\\krystian.txt";
- public Vector<Task> tasks = new Vector<Task>();
- public void addTask(Task x) {
- tasks.add(x);
- }
- public void flushTask(Client task) {
- tasks.remove(task);
- }
- public void clearTask() {
- tasks.clear();
- }
- public void showTask() {
- System.out.println("PC is containg: ");
- for (Task task : tasks) {
- System.out.println(task + " ");
- }
- }
- public void save() throws IOException {
- ObjectOutputStream oos = null;
- FileOutputStream fout = null;
- try {
- fout = new FileOutputStream(file, false);
- oos = new ObjectOutputStream(fout);
- oos.writeObject(tasks);
- } catch (Exception ex) {
- ex.printStackTrace();
- } finally {
- if (oos != null) {
- oos.close();
- }
- }
- }
- public void load() throws IOException, ClassNotFoundException {
- FileInputStream fis = new FileInputStream(file);
- ObjectInputStream ois = new ObjectInputStream(fis);
- tasks = (Vector<Task>)ois.readObject();
- ois.close();
- }
- @Override
- public String toString() {
- // TODO Auto-generated method stub
- return user;
- }
- }
- public class main {
- public static void main(String[] args) throws IOException, ClassNotFoundException {
- // TODO Auto-generated method stub
- Task x = new Task("xd3", "xddd3","wtf",new Date(), "lol", new Date());
- x.addTask(x);
- x.load();
- x.showTask();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement