How to convet reader to double? 0 Answer(s) 3 years ago
Posted in : Java Beginners
I have this set of coding which read the input from the com1 port. I wan to ask how to convert the input (the reader) into Double so that the input can perform arithmetic operation?
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
public static void main(String[] args) { portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals("COM1")) { // if (portId.getName().equals("/dev/term/a")) { SimpleRead reader = new SimpleRead();
public void serialEvent(SerialPortEvent event) { switch(event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: byte[] readBuffer = new byte[20];