If you have written a file upload component in VB, it is very easy to write a file upload JAVABEAN using JAVA.
The following example is just a simple version
package yuanyifileup;
import .*;
import .*;
import .*;
import .*;
import ;
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
{
=request;
=response;
=config;
DATA = ();
FormSize=();
}
public void initialize(PageContext pageContext) throws IOException
{
request=();
response=();
config=();
DATA = ();
FormSize=();
}
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=();
b[i]=t;
i++;
}
catch(EOFException e)
{ break;}
}
();}
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=("image/");
temp=(start1);
start1=("\r\n\r\n");
temp=(start1+4);
start2=(";\r\n");
if (start2!=-1)
{
temp=(0,start2);
}
try
{
byte[] img=("ISO8859_1");
for (i=0;i<;i++)
{ (img[i]); }
();
}
catch(IOException e)
{return(false);}
return(true);
}
If you don't understand E-Mail:yymailbox@
}
The following example is just a simple version
package yuanyifileup;
import .*;
import .*;
import .*;
import .*;
import ;
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
{
=request;
=response;
=config;
DATA = ();
FormSize=();
}
public void initialize(PageContext pageContext) throws IOException
{
request=();
response=();
config=();
DATA = ();
FormSize=();
}
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=();
b[i]=t;
i++;
}
catch(EOFException e)
{ break;}
}
();}
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=("image/");
temp=(start1);
start1=("\r\n\r\n");
temp=(start1+4);
start2=(";\r\n");
if (start2!=-1)
{
temp=(0,start2);
}
try
{
byte[] img=("ISO8859_1");
for (i=0;i<;i++)
{ (img[i]); }
();
}
catch(IOException e)
{return(false);}
return(true);
}
If you don't understand E-Mail:yymailbox@
}