发布时间:2016-01-08 10:09:41作者:知识屋
smartupload是什么 jspsmart是什么。jspSmartUpload是一款组件,用来对JSP进行程序开发过程中上传下载用的。而且还能支持下载中文名字的文件,非常简单方便,今天小编就分享下jspSmartUpload的组件源码给大家,希望大家喜欢。
JspSmart之upload组件源码主要包括了5个java文件
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);
fileoutputstream.close();
}
catch(IOException ioexception)
{
throw new SmartUploadException("File can't be saved (1120)。");
}
}
public void fileToField(ResultSet resultset, String s)
throws ServletException, IOException, SmartUploadException, SQLException
{
long l = 0L;
int i = 0x10000;
int j = 0;
int k = m_startData;
if(resultset == null)
throw new IllegalArgumentException("The RecordSet cannot be null (1145)。");
if(s == null)
throw new IllegalArgumentException("The columnName cannot be null (1150)。");
if(s.length() == 0)
throw new IllegalArgumentException("The columnName cannot be empty (1155)。");
l = BigInteger.valueOf(m_size)。divide(BigInteger.valueOf(i))。longValue();
j = BigInteger.valueOf(m_size)。mod(BigInteger.valueOf(i))。intValue();
try
{
for(int i1 = 1; (long)i1 < l; i1++)
{
resultset.updateBinaryStream(s, new ByteArrayInputStream(m_parent.m_binArray, k, i), i);
k = k != 0 ? k : 1;
k = i1 * i + m_startData;
}
if(j > 0)
resultset.updateBinaryStream(s, new ByteArrayInputStream(m_parent.m_binArray, k, j), j);
}
catch(SQLException sqlexception)
{
byte abyte0[] = new byte[m_size];
System.arraycopy(m_parent.m_binArray, m_startData, abyte0, 0, m_size);
resultset.updateBytes(s, abyte0);
}
catch(Exception exception)
{
throw new SmartUploadException("Unable to save file in the DataBase (1130)。");
}
}
public boolean isMissing()
{
return m_isMissing;
}
public String getFieldName()
{
return m_fieldname;
}
public String getFileName()
{
return m_filename;
}
public String getFilePathName()
{
return m_filePathName;
}
public String getFileExt()
{
return m_fileExt;
}
public String getContentType()
{
return m_contentType;
}
public String getContentDisp()
{
return m_contentDisp;
}
public String getContentString()
{
String s = new String(m_parent.m_binArray, m_startData, m_size);
return s;
}
public String getTypeMIME()
throws IOException
{
return m_typeMime;
}
public String getSubTypeMIME()
{
return m_subTypeMime;
}
public int getSize()
{
return m_size;
}
protected int getStartData()
{
return m_startData;
}
protected int getEndData()
{
return m_endData;
}
protected void setParent(SmartUpload smartupload)
{
m_parent = smartupload;
}
protected void setStartData(int i)
{
m_startData = i;
}
protected void setEndData(int i)
{
m_endData = i;
}
protected void setSize(int i)
{
m_size = i;
}
protected void setIsMissing(boolean flag)
{
m_isMissing = flag;
}
protected void setFieldName(String s)
{
m_fieldname = s;
}
protected void setFileName(String s)
{
m_filename = s;
}
protected void setFilePathName(String s)
{
m_filePathName = s;
}
protected void setFileExt(String s)
{
m_fileExt = s;
}
protected void setContentType(String s)
{
m_contentType = s;
}
protected void setContentDisp(String s)
{
以上就是smartupload和jspsmart的相关内容,希望大家喜欢。
2016-05-30
新浪秒拍视频怎么下载?秒拍视频下载的方法教程
监控怎么安装?网络监控摄像头安装图文教程
电脑待机时间怎么设置 电脑没多久就进入待机状态
农行网银K宝密码忘了怎么办?农行网银K宝密码忘了的解决方法
手机淘宝怎么修改评价 手机淘宝修改评价方法
支付宝钱包、微信和手机QQ红包怎么用?为手机充话费、淘宝购物、买电影票
不认识的字怎么查,教你怎样查不认识的字
如何用QQ音乐下载歌到内存卡里面
2015年度哪款浏览器好用? 2015年上半年浏览器评测排行榜!