下面为部分代码,该怎么改
 
 GIFEncoder gifEnc;
  showStatus("connecting!");
  java.net.URL url=new java.net.URL (URLString);
  java.net.URLConnection connection = url.openConnection();
   connection.setUseCaches(false);
   connection.setDoOutput(true);
   connection.setDoInput(true);
       // Data will always be written to a byte array buffer so
       // that we can tell the server the length of the data
   ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
       // Create the output stream to be used to write the data to our buffer
  ObjectOutputStream out = new ObjectOutputStream(byteOut);
  gifEnc=new GIFEncoder(bi);
  out.writeObject(gifEnc);
       // Flush the data to the buffer
  out.flush();
  byte buf[] = byteOut.toByteArray();
  connection.setRequestProperty("Content-type","image/gif");
  connection.setRequestProperty("Content-length","" + buf.length);
         // Get the output stream to the server and send our data buffer
  DataOutputStream dataOut =   new DataOutputStream(connection.getOutputStream());
  dataOut.write(buf);
       // Flush the output stream and close it
   dataOut.flush();
   dataOut.close();
   showStatus("sending!");