Skip to content

Java InputStream and OutputStream Interfacing Usage Example

Will Hedgecock edited this page Mar 12, 2015 · 9 revisions

If you prefer to use the standardized Java InputStream/OutputStream interfaces to interact with your serial port, you can do so with requesting these interfaces directly from the COM port object, as follows:

InputStream in = comPort.getInputStream(); try { for (int j = 0; j < 1000; ++j) System.out.print((char)in.read()); in.close(); } catch (Exception e) { e.printStackTrace(); }

Clone this wiki locally