From e56d39fea082b288f3abcb17da60b5fcf5efd23f Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Fri, 24 Jan 2014 09:15:19 +0300 Subject: [PATCH] Added "writeString(String string, String charsetName)" method --- src/java/jssc/SerialPort.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/java/jssc/SerialPort.java b/src/java/jssc/SerialPort.java index 01778b3..e5f43b4 100644 --- a/src/java/jssc/SerialPort.java +++ b/src/java/jssc/SerialPort.java @@ -24,7 +24,9 @@ */ package jssc; +import java.io.UnsupportedEncodingException; import java.lang.reflect.Method; +import java.nio.charset.Charset; /** * @@ -375,6 +377,20 @@ public class SerialPort { return writeBytes(string.getBytes()); } + /** + * Write String to port + * + * @return If the operation is successfully completed, the method returns true, otherwise false + * + * @throws SerialPortException + * + * @since 2.8.0 + */ + public boolean writeString(String string, String charsetName) throws SerialPortException, UnsupportedEncodingException { + checkPortOpened("writeString()"); + return writeBytes(string.getBytes(charsetName)); + } + /** * Write int value (in range from 0 to 255 (0x00 - 0xFF)) to port *