Writing to serial port is easy once you’ve got the serial port’s outputstream. Just do something like this:
String serialMessage = "AT\r\n"; OutputStream outstream = serialPort.getOutputStream(); outstream.write(serialMessage.getBytes());
Refer to my previous post for opening and getting the output stream for the serial port.
From wikibooks Serial Java, comes a good advice, do not use Reader/Writer for AT command, since Reader/Writer will translate the AT command into the Unicode (your code might work as it is, or might not work if you use different Unicode than latin/ISO-8859-1 as default Unicode in the system).