我想自定义(增加)一个文件的属性,比如:author属性,将来可以通过file.author()来获得,就像file.length()一样,怎么实现呢?

解决方案 »

  1.   

    ???
    class File{
      public String author;
      public int size;
      public File(){}
      public String getAuthor(){
          return(this.author);
      }
      public void setAuthor(String author){
          this.author=author;
      }
        .....
    }
      

  2.   

    谢谢你们!
    我初学jsp,
    能不能详细一点啊
      

  3.   

    public class myFile extends java.io.File{
        private String author;
        public myFile(String pathname)
        {
            super(pathname);
        }
        public String getAuthor(){
            return(this.author);
        }
        public void setAuthor(String author){
            this.author=author;
        }
    }