JspSmart upload Component source code mainly includes five java files
File. java
Import java. io. ByteArrayInputStream;
Import java. io. FileOutputStream;
Import java. io. IOException;
Import java. math. BigInteger;
Import java. SQL. ResultSet;
Import java. SQL. SQLException;
Import javax. servlet. ServletException;
// Referenced classes of package com. jspsmart. upload:
// SmartUploadException, SmartUpload
Public class File
{
Private SmartUpload m_parent;
Private int m_startData;
Private int m_endData;
Private int m_size;
Private String m_fieldname;
Private String m_filename;
Private String m_fileExt;
Private String m_filePathName;
Private String m_contentType;
Private String m_contentDisp;
Private String m_typeMime;
Private String m_subTypeMime;
Private String m_contentString;
Private boolean m_isMissing;
Public static final int SAVEAS_AUTO = 0;
Public static final int SAVEAS_VIRTUAL = 1;
Public static final int SAVEAS_PHYSICAL = 2;
File ()
{
M_startData = 0;
M_endData = 0;
M_size = 0;
M_fieldname = new String ();
M_filename = new String ();
M_fileExt = new String ();
M_filePathName = new String ();
M_contentType = new String ();
M_contentDisp = new String ();
M_typeMime = new String ();
M_subTypeMime = new String ();
M_contentString = new String ();
M_isMissing = true;
}
Public void saveAs (String s)
Throws IOException, SmartUploadException
{
SaveAs (s, 0 );
}
Public void saveAs (String s, int I)
Throws IOException, SmartUploadException
{
String s1 = new String ();
S1 = m_parent.getPhysicalPath (s, I );
If (s1 = null)
Throw new IllegalArgumentException ("There is no specified destination file (1140 ).");
Try
{
Java. io. File file = new java. io. File (s1 );
FileOutputStream fileoutputstream = new FileOutputStream (file );
Fileoutputstream. write (m_parent.m_binArray, m_startData, m_size );