public int getNewLineIndex(byte[] bytes, Charset charset) {
        String firstBytes = new String(bytes, charset);
        String separator = "\r\n";
        int index = firstBytes.indexOf("\r\n");
        int indexCR = firstBytes.indexOf("\r");
        int indexLF = firstBytes.indexOf("\n");
        if (indexCR != -1 && indexCR < index) {
            separator = "\r";
            index = indexCR;
        }
        if (indexLF != -1 && indexLF < index)
            separator = "\n";
        return getByteIndex(firstBytes, separator);
    }