Methods Summary |
---|
public void | close()Closes this connection and the underlying connection.
synchronized (this) {
if (isClosed) {
return;
}
isClosed = true;
}
input.close();
output.close();
conn.close();
|
public final int | getMaximumPacketSize()Returns the amount of data that can be successfully sent or received
in a single read/write operation.
return Configuration.getIntProperty("obex.packetLength.max", 0);
|
public javax.microedition.io.Connection | getUnderlyingConnection()Returns the underlying connection, or null if there is none.
return conn;
|
public int | read(byte[] inData)Reads the packet data into the specified buffer.
if (isClosed) {
throw new IOException("The connection is closed.");
}
if (inData == null) {
throw new NullPointerException("Input buffer is null.");
}
int size = getMaximumPacketSize();
int len = inData.length;
if (size == 0 || len <= size) {
return input.read(inData, 0, len);
}
int off = 0;
while (off < len) {
int count = input.read(inData, off, Math.min(size, len - off));
if (count == 0) {
break;
}
off += count;
}
return off;
|
public void | write(byte[] outData, int len)Transfer the len bytes from specified packet over the irda connection.
if (isClosed) {
throw new IOException("The connection is closed.");
}
if (outData == null) {
throw new NullPointerException("Output buffer is null.");
}
int size = getMaximumPacketSize();
if (size == 0 || len <= size) {
output.write(outData, 0, len);
return;
}
int off = 0;
while (off < len) {
int count = Math.min(size, len - off);
output.write(outData, off, count);
off += count;
}
|