一个用于安排项目时间表的Java程序
源代码在线查看: project.java
/* * $Id: Project.java,v 1.1.1.1 2001/03/20 22:17:39 mastermitch Exp $ * * 2001 (C) by Christian Garbs * * Licensed under GNU GPL (see COPYING for details) * */ package de.cgarbs.apps.jprojecttimer; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.PrintStream; import java.util.Date; public class Project { File file; String name; int timeScale; boolean anchored; Date start; TaskList tasks; boolean needsToBeSaved; public Project() { tasks = new TaskList(); needsToBeSaved = false; name=""; timeScale = 0; anchored = false; start = new Date(); } public void readFromStream(File file) { this.file = file; // ReadFromStream tasks.removeAllElements(); try { BufferedReader in = new BufferedReader(new FileReader(file)); String s = in.readLine(); if (s.equals("")) { in.readLine(); // Version name = in.readLine(); timeScale = Integer.parseInt(in.readLine()); anchored = Boolean.valueOf(in.readLine()).booleanValue(); start.setTime(Long.parseLong(in.readLine())); tasks.readFromStream(in); } in.close(); } catch (Exception e) { System.err.println(e); } } public File getFile() { return file; } public void setFile(File file) { this.file = file; } public boolean needsToBeSaved() { if (needsToBeSaved) { return true; } if (tasks.needsToBeSaved()) { return true; } return false; } public void hasBeenSaved() { needsToBeSaved=false; tasks.hasBeenSaved(); } public TaskList getTaskList() { return tasks; } public void writeToStream(PrintStream out) { out.println(""); out.println("1"); out.println(name); out.println(timeScale); out.println(anchored); out.println(start.getTime()); tasks.writeToStream(out); out.println(""); } }