使用jsp对文件进行操作

package test;
import java.io.*;
public class CatalogShow
{
private String fullPath;

public CatalogShow(){
fullPath="/";
}

public CatalogShow(String path)
{
fullPath=path;
}

public String decodeString(String src)
{
String des=null;
if(src!=null){
des=
"";
for(int i=0;i<src.length();i++)
{
if(src.charAt(i)==' '){
des+=
"%20";
}else{
des+=src.charAt(i);
}
}
}
return des;
}
public String addPath(String fileName)
{
String result=
"";

if(fullPath.charAt(fullPath.length()-1)=='\\')
{
result=fullPath+fileName;
}else{
result=fullPath+'\\'+fileName;
}

return decodeString(result);
}

public void setPath(String path)
{
fullPath=path;
}

public String dirUp(String path)
{
String result=
"";
File dir=new File(path);
result=dir.getParent();
return decodeString(result);
}

public File[] listFiles()
{
File dir=new File(fullPath);
String[] ss=dir.list();
if(ss==null)
return null;
int n=ss.length;
File[] fs=new File[n];
for(int i=0;i<n;i++)
{
fs<i>=new File(dir.getPath(),ss<i>);
}
return fs;
}
}
lunzi   2005-06-13 02:16:44 评论:0   阅读:2453   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog