Hi,

Iam facing problem when iam writing a file in servlet
for uploading it giving me
error[Error:java.lang.StringIndexOutOfBoundsException:
String index out of range: -170].Iam writing file part
wise means by 2kb of total size of file.Any help will
be highly appreciated.Iam attaching those portion of
my programme where Iam writing file.
code:-
-----
class SimulatedActivity extends Thread
.........
..............
public void run()
{
 int k=(int)bb.length(); //bb is File object iam
selecting file by opening file dialog box by clicking
button of interface.
byte buff[]=new byte[2048];
do
  {
   try{
         sleep(1000);
      }
        catch(InterruptedException e)
                {
                  return;
                }
  try
     {

totLengthWritten+=lengthWritten=fileIn.read(buff,0,2048);

        // upload this buff[] on stream opened on
urlconn
String
preContent="-----------------------------7d11e410e500f2\r\nContent-Disposition:
form-data;name=\"upload\";filename=\""+bb+"\"\r\nContent-Type:application/octet-stream\r\n\r\n";
printout.writeBytes(preContent);
printout.write(buff,0,lengthWritten);}
catch(Exception e1){System.out.println("Error from
write=" +e1.toString());}while(totLengthWritten<target
&& !interrupted());
do
 {
  try
   {
  String postContent =
"\r\n-----------------------------7d11e410e500f2--\r\n";
        printout.writeBytes(postContent);
        printout.flush ();
        printout.close ();
   }
catch(Exception e1){System.out.println("Error from
End=" +e1.toString());}
}while(totLengthWritten==target);

Thanks for ur valuable Time
Bikash




__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to