Java Reference
In-Depth Information
L ISTING 6.6
Continued
6
// Set this to false in order to ignore caching
connection.setUseCaches(false);
// Set the content-type of the request
// application/octet-stream is used when writing
// application specific byte size data
connection.setRequestProperty(“CONTENT_TYPE”,
“application/octet-stream”);
// Set these vales to true to use the same connection
// for both input and output
connection.setDoInput(true);
connection.setDoOutput(true);
// Create the ObjectOutputStream passing it the
// ByteArrayOutputStream object.
ObjectOutputStream os =
new ObjectOutputStream(connection.getOutputStream());
// Write the StudentList to the ObjectOutputStream
System.err.println(“Writing Order Object.”);
os.writeObject(value);
os.flush();
os.close();
}
catch (IOException e) {
System.err.println(e.getMessage());
}
}
public Order readOrder(URLConnection connection)
{
Order order = null;
try {
// Create the ObjectInputStream passing it the
// InputStream object from the URLConnection
ObjectInputStream is = new ObjectInputStream(
connection.getInputStream());
System.err.println(“Waiting for response.”);
 
Search WWH ::




Custom Search