We are about to switch to a new forum software. Until then we have removed the registration on this forum.
The following line of code produces an "ArrayIndexOutOfBoundsException" when no COM port exist.
myPort = new Serial(this, Serial.list()[0], 57600);
How do I check Serail.list() return value for an empty string array to avoid an exception?
Obviously the following will not work cause index 0 does not exist:
if (Serial.list()[0].length() != 0)
{
myPort = new Serial(this, Serial.list()[0], 57600);
}
Answers