Methods Summary |
---|
public void | close()
try
{
mObjectInStream.close();
mObjectOutStream.close();
}
catch(Exception e)
{
Debug.printStackTrace(e);
}
|
private void | handleException(java.io.IOException e)
IOException exception = null;
if (e instanceof java.net.UnknownHostException)
{
exception = new java.net.UnknownHostException(UNKNOWN_HOST +
e.getMessage());
}
else if (e instanceof java.net.ConnectException)
{
exception = new java.net.ConnectException(INVALID_HOST_PORT);
}
else
{
int responseCode =
((HttpURLConnection)mConnection).getResponseCode();
if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED)
{
exception = new IOException(UNAUTHORIZED_ACCESS);
}
else
{
exception = e;
}
}
throw exception;
|
public java.lang.Object | receive()Read an incoming Object.
Object value = null;
try
{
mObjectInStream = new ObjectInputStream(
new BufferedInputStream(mConnection.getInputStream()));
value = mObjectInStream.readObject();
}
catch (IOException ioe)
{
handleException(ioe);
}
return value;
|
public void | send(java.io.Serializable object)Write an object to the connection
try
{
mObjectOutStream = new ObjectOutputStream(
new BufferedOutputStream(
mConnection.getOutputStream()));
mObjectOutStream.writeObject(object);
mObjectOutStream.flush();
mObjectOutStream.close();
}
catch (IOException ioe)
{
handleException(ioe);
}
|