次のコードで例外が発生します。UUID とは何かを理解できません。誰でもこのエラーを解決できますか? コードとエラーを投稿しました。
package wiki.nokia.example;
import java.io.IOException;
import javax.bluetooth.BluetoothStateException;
import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.L2CAPConnection;
import javax.bluetooth.L2CAPConnectionNotifier;
import javax.bluetooth.LocalDevice;
import javax.microedition.io.Connector;
public class BluetoothServer implements Runnable {
private boolean listening = true;
private LocalDevice local_device;
private BtoothChat midlet;
private String deviceName;
private L2CAPConnection con;
/** Creates a new instance of BluetoothServer */
public BluetoothServer(BtoothChat midlet) {
this.midlet = midlet;
Thread t = new Thread(this);
t.start();
}
public void run(){
System.out.println("Starting server - please wait...");
try {
local_device = LocalDevice.getLocalDevice();
DiscoveryAgent disc_agent = local_device.getDiscoveryAgent();
local_device.setDiscoverable(DiscoveryAgent.LIAC);
String service_UUID = "9";
deviceName = local_device.getFriendlyName();
String url = "btl2cap://localhost:" + service_UUID + ";name=" + deviceName;
L2CAPConnectionNotifier notifier = (L2CAPConnectionNotifier)Connector.open(url);
con = notifier.acceptAndOpen();
while (listening) {
if (con.ready()){
byte[] b = new byte[1000];
con.receive(b);
String s = new String(b, 0, b.length);
System.out.println("Recieved from client: " + s.trim());
midlet.setAlert(s.trim());
send("Hello client, my name is: " + getName());
listening=false;
}
}
} catch(BluetoothStateException e){System.out.println(e);} catch(IOException f){System.out.println(f);}
}
private void send(String s){
byte[] b = s.getBytes();
try {
con.send(b);
} catch(IOException e){
System.out.println(e);
}
}
private String getName(){
return deviceName;
}
}
エラー:
Starting server - please wait...
Uncaught exception: java.lang.NumberFormatException
at java.lang.Long.parseLong(Long.java:401)
at javax.bluetooth.UUID.<init>(), bci=166
at com.sun.jsr082.bluetooth.btl2cap.L2CAPNotifierImpl.createServiceRecord(), bci=26
at com.sun.jsr082.bluetooth.btl2cap.L2CAPNotifierImpl.<init>(), bci=122
at com.sun.jsr082.bluetooth.btl2cap.Protocol.serverConnection(), bci=16
at com.sun.jsr082.bluetooth.BluetoothProtocol.openPrimImpl(), bci=24
at com.sun.jsr082.bluetooth.BluetoothProtocol.openPrim(), bci=14
at com.sun.midp.io.j2me.btl2cap.Protocol.openPrim(), bci=7
at javax.microedition.io.Connector.openPrim(), bci=327
at javax.microedition.io.Connector.open(), bci=3
at javax.microedition.io.Connector.open(), bci=3
at javax.microedition.io.Connector.open(), bci=2
at wiki.nokia.example.BluetoothServer.run(BluetoothServer.java:48)
at java.lang.Thread.run(), bci=11