|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
用jsp编写文件上载
如果你曾用VB编写文件上传的组件的话,那么用java编写文件上传的JAVABEAN十分容易。
下面的例子只是一个简版
package yuanyifileup;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.PageContext;
public class yuanyifileup
{www.bjkfp12.com,www.cckfp12.com,www.cskfp12.com,
PRivate ServletRequest request;
private ServletResp**e resp**e;
private ServletConfig config;
ServletInputStream DATA;
int FormSize;
File f1;
FileOutputStream os;
DataInputStream is;
String filename;
byte[] b;
byte t;www.dlkfp12.com,www.hfkfp12.com,www.hzkfp12.com,
boolean flag=false;
public yuanyifileup()
{ www.jnkfp12.com, www.njkfp12.com, www.qdkfp12.com,
}
public void initialize(ServletConfig config,HttpServletRequest request,HttpServletResp**e resp**e) throws IOException
{
this.request=request;
this.resp**e=resp**e;
this.config=config;
DATA = request.getInputStream();
FormSize=request.getContentLength(www.shkfp12.com,www.sykfp12.com,www.szkfp12.com);
}
public void initialize(PageContext pageContext) throws IOException
{
request=pageContext.getRequest();
resp**e=pageContext.getResp**e();
config=pageContext.getServletConfig();
DATA = request.getInputStream();
FormSize=request.getContentLength();
}
public boolean setFilename(String s)
{
try
{
File f1=new File(s);
os=new FileOutputStream(f1);
}
catch(IOException e)
{return(false);}
return(true);
}
public void getByte()
{
int i=0;
try
{
is=new DataInputStream(DATA);
b=new byte[FormSize];
while (true)
{
try
{
t=is.readByte();
b[i]=t;
i++;
|
|