aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/helper/BufferUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/helper/BufferUtil.java')
-rw-r--r--src/main/java/org/traccar/helper/BufferUtil.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/helper/BufferUtil.java b/src/main/java/org/traccar/helper/BufferUtil.java
index d1025f548..12c31ba9d 100644
--- a/src/main/java/org/traccar/helper/BufferUtil.java
+++ b/src/main/java/org/traccar/helper/BufferUtil.java
@@ -71,4 +71,16 @@ public final class BufferUtil {
}
}
+ public static boolean isPrintable(ByteBuf buf, int length) {
+ boolean printable = true;
+ for (int i = 0; i < length; i++) {
+ byte b = buf.getByte(buf.readerIndex() + i);
+ if (b < 32 && b != '\r' && b != '\n') {
+ printable = false;
+ break;
+ }
+ }
+ return printable;
+ }
+
}