javabean 不知道那里出错了 希望大家帮忙 谢谢
该程序是打开指定目录中特定扩展名的文件
package tom.jiafei;
import java.io.*;
class FileName implements FilenameFilter{
String str=null;
FileName(String s){
str="."+s;
}
public boolean accept(File dir,String name){
return name.endsWith(str);
}
}
public class ListFile{
String extendsName=null;
StringBuffer allFileName;
public void setExtendsName(String s){
extendsName=s;
}
public String getExtendsName(){
return extendsName;
}
public StringBuffer getAllFileName(){
File dir=new File("d:/");
FileName help=new FileName(extendsName);
String file_name[]=dir.list(help);
for(int i=0;i<file_name.length;i++){
allFileName.append(file_name[i]+"");
}
return allFileName;
}
}
_________________________________________________________
<%@page contentType="text/html;Charset=GB2312"%>
<%@page import="tom.jiafei.*"%>
<jsp:useBean id="file" scope="page"/>
<html>
<body>
<form action="" method="post">
输入文件的扩展名:<input type=text name="extendsName">
<input type=submit value="提交">
</form>
<jsp:setProperty name="file" property="extendsName" param="extendsName"/>
<P>
扩展名:<jsp:getProperty name="file" property="extendsName"/>
的文件有:<br>
<jsp:getProperty name="file" property="allFileName"/>
</body>
</html>
file.jsp