下面为部分代码,该怎么改
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!");
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!");
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货