JspSmart之upload组件源码主要包括了5个java文件File.javaimportjava.io.ByteArrayInputStream;importjava.io.FileOutputStream;importjava.io.IOException;importjava.math.BigInteger;importjava.sql.ResultSet;importjava.sql.SQLException;importjavax.servlet.ServletException;//Referencedclassesofpackagecom.jspsmart.upload://SmartUploadException,SmartUploadpublicclassFile{privateSmartUploadm_parent;privateintm_startData;privateintm_endData;privateintm_size;privateStringm_fieldname;privateStringm_filename;privateStringm_fileExt;privateStringm_filePathName;privateStringm_contentType;privateStringm_contentDisp;privateStringm_typeMime;privateStringm_subTypeMime;privateStringm_contentString;privatebooleanm_isMissing;publicstaticfinalintSAVEAS_AUTO=0;publicstaticfinalintSAVEAS_VIRTUAL=1;publicstaticfinalintSAVEAS_PHYSICAL=2;File(){m_startData=0;m_endData=0;m_size=0;m_fieldname=newString();m_filename=newString();m_fileExt=newString();m_filePathName=newString();m_contentType=newString();m_contentDisp=newString();m_typeMime=newString();m_subTypeMime=newString();m_contentString=newString();m_isMissing=true;}publicvoidsaveAs(Strings)throwsIOException,SmartUploadException{saveAs(s,0);}publicvoidsaveAs(Strings,inti)throwsIOException,SmartUploadException{Strings1=newString();s1=m_parent.getPhysicalPath(s,i);if(s1==null)thrownewIllegalArgumentException(Thereisnospecifieddestinationfile(1140).);try{java.io.Filefile=newjava.io.File(s1);FileOutputStreamfileoutputstream=newFileOutputStream(file);fileoutputstream.write(m_parent.m_binArray,m_startData,m_size);fileoutputstream.close();}catch(IOExceptionioexception){thrownewSmartUploadException(Filecan'tbesaved(1120).);}}publicvoidfileToField(ResultSetresultset,Strings)throwsServletException,IOException,SmartUploadException,SQLException{longl=0L;inti=0x10000;intj=0;intk=m_startData;if(resultset==null)thrownewIllegalArgumentException(TheRecordSetcannotbenull(1145).);if(s==null)thrownewIllegalArgumentException(ThecolumnNamecannotbenull(1150).);if(s.length()==0)thrownewIllegalArgumentException(ThecolumnNamecannotbeempty(1155).);l=BigInteger.valueOf(m_size).divide(BigInteger.valueOf(i)).longValue();j=BigInteger.valueOf(m_size).mod(BigInteger.valueOf(i)).intValue();try{for(inti1=1;(long)i1l;i1++){resultset.updateBinaryStream(s,newByteArrayInputStream(m_parent.m_binArray,k,i),i);k=k!=0?k:1;k=i1*i+m_startData;}if(j0)resultset.updateBinaryStream(s,newByteArrayInputStream(m_parent.m_binArray,k,j),j);}catch(SQLExceptionsqlexception){byteabyte0[]=newbyte[m_size];System.arraycopy(m_parent.m_binArray,m_startData,abyte0,0,m_size);resultset.updateBytes(s,abyte0);}catch(Exceptionexception){thrownewSmartUploadException(UnabletosavefileintheDataBase(1130).);}}publicbooleanisMissing(){returnm_isMissing;}publicStringgetFieldName(){returnm_fieldname;}publicStringgetFileName(){returnm_filename;}publicStringgetFilePathName(){returnm_filePathName;}publicStringgetFileExt(){returnm_fileExt;}publicStringgetContentType(){returnm_contentType;}publicStringgetContentDisp(){returnm_contentDisp;}publicStringgetContentString(){Strings=newString(m_parent.m_binArray,m_startData,m_size);returns;}publicStringgetTypeMIME()throwsIOException{returnm_typeMime;}publicStringgetSubTypeMIME(){returnm_subTypeMime;}publicintgetSize(){returnm_size;}protectedintgetStartData(){returnm_startData;}protectedintgetEndData(){returnm_endData;}protectedvoidsetParent(SmartUploadsmartupload){m_parent=smartupload;}protectedvoidsetStartData(inti){m_startData=i;}protectedvoidsetEndData(inti){m_endData=i;}protectedvoidsetSize(inti){m_size=i;}protectedvoidsetIsMissing(booleanflag){m_isMissing=flag;}protectedvoidsetFieldName(Strings){m_fieldname=s;}protectedvoidsetFileName(Strings){m_filename=s;}protectedvoidsetFilePathName(Strings){m_filePathName=s;}protectedvoidsetFileExt(Strings){m_fileExt=s;}protectedvoidsetContentType(Strings){m_contentType=s;}protectedvoidsetContentDisp(Strings){m_contentDisp=s;}protectedvoidsetTypeMIME(Strings){m_typeMime=s;}protectedvoidsetSubTypeMIME(Strings){m_subTypeMime=s;}publicbytegetBinaryData(inti){if(m_startData+im_endData)thrownewArrayIndexOutOfBoundsException(IndexOutofrange(1115).);if(m_startData+i=m_endData)returnm_parent.m_binArray[m_startData+i];elsereturn0;}}///////////////////////////////Files.javaimportjava.io.IOException;importjava.util.*;//Referencedclassesofpackagecom.jspsmart.upload://File,SmartUploadpublicclassFiles{privateSmartUploadm_parent;privateHashtablem_files;privateintm_counter;Files(){m_files=newHashtable();m_counter=0;}protectedvoidaddFile(Filefile){if(file==null){thrownewIllegalArgumentException(newFilecannotbenull.);}else{m_files.put(newInteger(m_counter),file);m_counter++;return;}}publicFilegetFile(inti){if(i0)thrownewIllegalArgumentException(File'sindexcannotbeanegativevalue(1210).);Filefile=(File)m_files.get(newInteger(i));if(file==null)thrownewIllegalArgumentException(Files'nameisinvalidordoesnotexist(1205).);elsereturnfile;}publicintgetCount(){returnm_counter;}publiclonggetSize()throwsIOException{longl