Example usage for io.netty.buffer ByteBufUtil indexOf

List of usage examples for io.netty.buffer ByteBufUtil indexOf

Introduction

In this page you can find the example usage for io.netty.buffer ByteBufUtil indexOf.

Prototype

public static int indexOf(ByteBuf needle, ByteBuf haystack) 

Source Link

Document

Returns the reader index of needle in haystack, or -1 if needle is not in haystack.

Usage

From source file:org.traccar.helper.BufferUtil.java

License:Apache License

public static int indexOf(String needle, ByteBuf haystack) {
    ByteBuf needleBuffer = Unpooled.wrappedBuffer(needle.getBytes(StandardCharsets.US_ASCII));
    try {//w  w  w .j a  v a 2s . c o m
        return ByteBufUtil.indexOf(needleBuffer, haystack);
    } finally {
        needleBuffer.release();
    }
}