站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题我想自定义(增加)一个文件的属性,比如:author属性,将来可以通过file.author()来获得,就像file.length()一样,怎么实现呢?

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

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


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


通过继承实现一个File对象。


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


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


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;
}
}


↑返回目录
前一篇: 分析需求,和写程序. 哪个简单?
后一篇: 请高手指教,为什么联不上数据库?谢谢