資源簡介
一個相當經典的網盤系統 具有所有的功能 是初學者最好的學習案例
代碼片段和文件信息
package?com.lhq.prj.dd.action;
import?java.io.File;
import?java.io.FileInputStream;
import?java.io.FileNotFoundException;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.io.InputStream;
import?java.io.UnsupportedEncodingException;
import?java.net.URLDecoder;
import?java.util.ArrayList;
import?java.util.Date;
import?java.util.List;
import?org.apache.tools.zip.ZipOutputStream;
import?com.lhq.prj.dd.core.baseAction;
import?com.lhq.prj.dd.core.MyUtils;
import?com.lhq.prj.dd.core.Page;
import?com.lhq.prj.dd.json.bean.MyFile;
/**
?*?FileAction.java?Create?on?2008-12-18?上午09:16:22
?*?
?*?說明:文件處理
?*?
?*?Copyright?(c)?2008?by?yourgame.
?*?
?*?@author?廖瀚卿
?*?@version?1.0
?*/
@SuppressWarnings(“serial“)
public?class?FileAction?extends?baseAction?{
public?static?final?String?ROOT?=?“root\\“;
private?File?myUpload;
private?String?myUploadContentType;
private?String?myUploadFileName;
private?String?path;
private?String?node;
private?List?nodes;
private?Page?page;
private?String?name;
private?String[]?paths;
private?boolean?success;
/**
?*?處理中文下載名
?*?
?*?@return
?*?@throws?UnsupportedEncodingException
?*/
public?String?getDownloadFileName()?throws?UnsupportedEncodingException?{
String?named?=?new?String(name.getBytes()?“ISO8859-1“);
return?named;
}
/**
?*?獲得文件下載流
?*?
?*?@return
?*?@throws?FileNotFoundException
?*/
public?InputStream?getInputStream()?throws?FileNotFoundException?{
return?getServletContext().getResourceAsStream(ROOT?+?path?+?“/“?+?name);
}
/**
?*?下載文件
?*?
?*?@return
?*/
public?String?download()?{
return?SUCCESS;
}
/**
?*?解壓縮文件
?*?
?*?@return
?*/
public?String?decompressionFiles()?{
String?rootPath?=?getSession().getServletContext().getRealPath(“/“);
rootPath?+=?ROOT;
File?file?=?new?File(rootPath);
if(!file.exists()){
file.mkdirs();
}
file?=?null;
String?extName?toPath?absPath;
boolean?flag?=?false;
try?{
for?(String?path?:?paths)?{
file?=?new?File(rootPath?+?path);
if?(file.isDirectory())?{
continue;
}
extName?=?path.substring(path.lastIndexOf(“.“)?+?1).toLowerCase();
toPath?=?rootPath?+?(((getPath()?!=?null)?&&?(getPath().length()?>?0))???getPath().substring(1)?:?““)
+?“\\“;
absPath?=?file.getAbsolutePath();
if?(“zip“.equals(extName))?{
flag?=?MyUtils.decompressionZipFiles(absPath?toPath);
}?else?if?(“rar“.equals(extName))?{
flag?=?MyUtils.decompressionRarFiles(absPath?toPath);
}
}
}?catch?(RuntimeException?e)?{
flag?=?false;
e.printStackTrace();
}?finally?{
file?=?null;
}
setSuccess(flag);
return?SUCCESS;
}
/**
?*?多文件下載
?*?
?*?@throws?IOException
?*/
public?String?downloadAll()?throws?IOException?{
// String?rootPath?=?getSession().getServletContext().getRealPath(“/“);
return?SUCCESS;
}
// public?I
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????345??2009-03-21?18:00??.settings\org.eclipse.core.resources.prefs
?????目錄??????????0??2009-01-07?23:29??.settings
?????文件????????727??2009-03-20?19:41??src\applicationContext-actions.xm
?????文件???????2317??2009-02-16?01:27??src\struts.xm
?????文件????????701??2008-12-27?20:28??src\log4j.properties
?????文件????????102??2008-12-27?20:28??src\struts.properties
?????文件???????1381??2009-01-27?21:31??src\com\lhq\prj\dd\json\bean\MyFile.java
?????目錄??????????0??2009-01-07?23:29??src\com\lhq\prj\dd\json\bean
?????目錄??????????0??2009-01-07?23:29??src\com\lhq\prj\dd\json
?????文件???????1312??2009-03-22?23:20??src\com\lhq\prj\dd\core\ba
?????文件??????21044??2009-03-22?10:39??src\com\lhq\prj\dd\core\MyUtils.java
?????文件???????1552??2008-12-27?20:28??src\com\lhq\prj\dd\core\Page.java
?????目錄??????????0??2009-01-07?23:29??src\com\lhq\prj\dd\core
?????文件??????10444??2009-03-22?23:20??src\com\lhq\prj\dd\action\FileAction.java
?????目錄??????????0??2009-01-07?23:29??src\com\lhq\prj\dd\action
?????目錄??????????0??2009-01-07?23:29??src\com\lhq\prj\dd
?????目錄??????????0??2009-01-07?23:29??src\com\lhq\prj
?????目錄??????????0??2009-01-07?23:29??src\com\lhq
?????目錄??????????0??2009-01-07?23:29??src\com
?????目錄??????????0??2009-01-07?23:29??src
?????文件???????1352??2009-03-21?00:19??WebRoot\index.jsp
?????文件??????53877??2008-12-27?20:26??WebRoot\resources\resources.jsb
?????文件????????120??2009-01-07?09:26??WebRoot\resources\images\ext\orange\progress\progress-bg.gif
?????目錄??????????0??2009-01-07?23:28??WebRoot\resources\images\ext\orange\progress
?????文件?????????62??2008-12-27?20:27??WebRoot\resources\images\ext\orange\tabs\tab-strip-bg.gif
?????文件????????181??2008-12-27?20:27??WebRoot\resources\images\ext\orange\tabs\tab-btm-inactive-left-bg.gif
?????文件????????565??2008-12-27?20:27??WebRoot\resources\images\ext\orange\tabs\tab-btm-inactive-right-bg.gif
?????文件????????576??2008-12-27?20:27??WebRoot\resources\images\ext\orange\tabs\tab-btm-right-bg.gif
?????文件?????????62??2008-12-27?20:27??WebRoot\resources\images\ext\orange\tabs\tab-strip-btm-bg.gif
?????文件???????1218??2008-12-27?20:27??WebRoot\resources\images\ext\orange\tabs\tabs-sprite.gif
............此處省略2367個文件信息
- 上一篇:CMVS-PMVS-master
- 下一篇:雄邁客戶端及修改IP工具
評論
共有 條評論