当前页面: 开发资料首页 → 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;
}
}