java属性类(Properties类)

import java.util.*;
import java.io.*;
class  AboutDate
{
 public static void main(String[] args)
 {
  Properties p = new Properties();
  Properties p1 = new Properties();
  p.setProperty("Title","The java training");

  try
  {
   p.store(new FileOutputStream("property.why"),"about");
  }
  catch(IOException e)
  {
   e.printStackTrace();
  }
  catch(Exception e)
  {
   e.printStackTrace();
  }
  try
  {
   p1.load(new FileInputStream("property.why"));
   System.out.println(p1.getProperty("T2itle", "Error"));

  }
  catch(Exception e)
  {
  }
  Date d1 = new Date();
  System.out.println(d1.getHours());
  System.out.println(d1.getDay());
  System.out.println(d1.getYear());
  System.out.println(d1.getMonth());
 }
}

posted @ 2004-10-25 21:00  轻松  阅读(1501)  评论(0编辑  收藏  举报