Package yuanyifileup;
Import java.io.*;
Import java.util.*;
Import javax.servlet.*;
Import javax.servlet.http.*;
Import Javax.servlet.jsp.PageContext;
public class Yuanyifileup
{
private ServletRequest request;
Private Servletresponse response;
Private ServletConfig config;
ServletInputStream DATA;
int formsize;
File F1;
FileOutputStream OS;
DataInputStream is;
String filename;
Byte[] B;
BYTE T;
Boolean flag=false;
Public Yuanyifileup ()
{ }
public void Initialize (ServletConfig config,httpservletrequest request,httpservletresponse response) throws IOException
{
This.request=request;
This.response=response;
This.config=config;
DATA = Request.getinputstream ();
Formsize=request.getcontentlength ();
}
public void Initialize (PageContext pagecontext) throws IOException
{
Request=pagecontext.getrequest ();
Response=pagecontext.getresponse ();
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++;
}
catch (Eofexception e)
{break;}
}
Is.close ();}
catch (IOException E)
{}
}
public Boolean Save ()
{
int i=0,start1=0,start2=0;
String temp= "";
if (!flag)
{
GetByte ();
Flag=true;
}
Try
{
Temp=new String (b, "iso8859_1");
}
catch (Unsupportedencodingexception e)
{return (false);}
Start1=temp.indexof ("image/");
Temp=temp.substring (START1);
Start1=temp.indexof ("");
Temp=temp.substring (START1+4);
Start2=temp.indexof (";");
if (start2!=-1)
{
Temp=temp.substring (0,START2);
}
Try
{
Byte[] Img=temp.getbytes ("iso8859_1");
for (i=0;i{os.write (img[i]);}
Os.close ();
}
catch (IOException E)
{return (false);}
return (true);
}
If there's a e-mail:yymailbox@263.net.bye that doesn't understand
}