cn.hutool.core.util.StrUtil.containsIgnoreCase()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(371)

本文整理了Java中cn.hutool.core.util.StrUtil.containsIgnoreCase()方法的一些代码示例,展示了StrUtil.containsIgnoreCase()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StrUtil.containsIgnoreCase()方法的具体详情如下:
包路径:cn.hutool.core.util.StrUtil
类名称:StrUtil
方法名:containsIgnoreCase

StrUtil.containsIgnoreCase介绍

[英]是否包含特定字符,忽略大小写,如果给定两个参数都为null,返回true
[中]是否包含特定字符,忽略大小写,如果给定两个参数都为null,返回符合事实的

代码示例

代码示例来源:origin: looly/hutool

charsetInContent = Charset.forName(charsetInContentStr);
} catch (Exception e) {
  if (StrUtil.containsIgnoreCase(charsetInContentStr, "utf-8") || StrUtil.containsIgnoreCase(charsetInContentStr, "utf8")) {
    charsetInContent = CharsetUtil.CHARSET_UTF_8;
  } else if (StrUtil.containsIgnoreCase(charsetInContentStr, "gbk")) {
    charsetInContent = CharsetUtil.CHARSET_GBK;

代码示例来源:origin: looly/hutool

charsetInContent = Charset.forName(charsetInContentStr);
} catch (Exception e) {
  if (StrUtil.containsIgnoreCase(charsetInContentStr, "utf-8") || StrUtil.containsIgnoreCase(charsetInContentStr, "utf8")) {
    charsetInContent = CharsetUtil.CHARSET_UTF_8;
  } else if (StrUtil.containsIgnoreCase(charsetInContentStr, "gbk")) {
    charsetInContent = CharsetUtil.CHARSET_GBK;

代码示例来源:origin: looly/hutool

/**
 * 查找指定字符串是否包含指定字符串列表中的任意一个字符串,如果包含返回找到的第一个字符串<br>
 * 忽略大小写
 * 
 * @param str 指定字符串
 * @param testStrs 需要检查的字符串数组
 * @return 被包含的第一个字符串
 * @since 3.2.0
 */
public static String getContainsStrIgnoreCase(CharSequence str, CharSequence... testStrs) {
  if (isEmpty(str) || ArrayUtil.isEmpty(testStrs)) {
    return null;
  }
  for (CharSequence testStr : testStrs) {
    if (containsIgnoreCase(str, testStr)) {
      return testStr.toString();
    }
  }
  return null;
}

代码示例来源:origin: looly/hutool

/**
 * 查找指定字符串是否包含指定字符串列表中的任意一个字符串,如果包含返回找到的第一个字符串<br>
 * 忽略大小写
 * 
 * @param str 指定字符串
 * @param testStrs 需要检查的字符串数组
 * @return 被包含的第一个字符串
 * @since 3.2.0
 */
public static String getContainsStrIgnoreCase(CharSequence str, CharSequence... testStrs) {
  if (isEmpty(str) || ArrayUtil.isEmpty(testStrs)) {
    return null;
  }
  for (CharSequence testStr : testStrs) {
    if (containsIgnoreCase(str, testStr)) {
      return testStr.toString();
    }
  }
  return null;
}

代码示例来源:origin: looly/hutool

@Override
protected SqlBuilder wrapPageSql(SqlBuilder find, Page page) {
  if (false == StrUtil.containsIgnoreCase(find.toString(), "order by")) {
    //offset 分页必须要跟在order by后面,没有情况下补充默认排序
    find.append(" order by current_timestamp");
  }
  return find.append(" offset ")
      .append(page.getStartPosition())//
      .append(" row fetch next ")//row和rows同义词
      .append(page.getPageSize())//
      .append(" row only");//
}

代码示例来源:origin: looly/hutool

@Override
protected SqlBuilder wrapPageSql(SqlBuilder find, Page page) {
  if (false == StrUtil.containsIgnoreCase(find.toString(), "order by")) {
    //offset 分页必须要跟在order by后面,没有情况下补充默认排序
    find.append(" order by current_timestamp");
  }
  return find.append(" offset ")
      .append(page.getStartPosition())//
      .append(" row fetch next ")//row和rows同义词
      .append(page.getPageSize())//
      .append(" row only");//
}

代码示例来源:origin: looly/hutool

/**
 * 读取主体,忽略EOFException异常
 * @param in 输入流
 * @return 自身
 * @throws IORuntimeException IO异常
 */
private void readBody(InputStream in) throws IORuntimeException{
  if(ignoreBody) {
    return;
  }
  
  int contentLength = Convert.toInt(header(Header.CONTENT_LENGTH), 0);
  final FastByteArrayOutputStream out = contentLength > 0 ? new FastByteArrayOutputStream(contentLength) : new FastByteArrayOutputStream();
  try {
    IoUtil.copy(in, out);
  } catch (IORuntimeException e) {
    if(e.getCause() instanceof EOFException || StrUtil.containsIgnoreCase(e.getMessage(), "Premature EOF")) {
      //忽略读取HTTP流中的EOF错误
    }else {
      throw e;
    }
  }
  this.bodyBytes = out.toByteArray();
}

代码示例来源:origin: looly/hutool

/**
 * 读取主体,忽略EOFException异常
 * @param in 输入流
 * @return 自身
 * @throws IORuntimeException IO异常
 */
private void readBody(InputStream in) throws IORuntimeException{
  if(ignoreBody) {
    return;
  }
  
  int contentLength = Convert.toInt(header(Header.CONTENT_LENGTH), 0);
  final FastByteArrayOutputStream out = contentLength > 0 ? new FastByteArrayOutputStream(contentLength) : new FastByteArrayOutputStream();
  try {
    IoUtil.copy(in, out);
  } catch (IORuntimeException e) {
    if(e.getCause() instanceof EOFException || StrUtil.containsIgnoreCase(e.getMessage(), "Premature EOF")) {
      //忽略读取HTTP流中的EOF错误
    }else {
      throw e;
    }
  }
  this.bodyBytes = out.toByteArray();
}

代码示例来源:origin: cn.hutool/hutool-all

charsetInContent = Charset.forName(charsetInContentStr);
} catch (Exception e) {
  if (StrUtil.containsIgnoreCase(charsetInContentStr, "utf-8") || StrUtil.containsIgnoreCase(charsetInContentStr, "utf8")) {
    charsetInContent = CharsetUtil.CHARSET_UTF_8;
  } else if (StrUtil.containsIgnoreCase(charsetInContentStr, "gbk")) {
    charsetInContent = CharsetUtil.CHARSET_GBK;

代码示例来源:origin: cn.hutool/hutool-http

charsetInContent = Charset.forName(charsetInContentStr);
} catch (Exception e) {
  if (StrUtil.containsIgnoreCase(charsetInContentStr, "utf-8") || StrUtil.containsIgnoreCase(charsetInContentStr, "utf8")) {
    charsetInContent = CharsetUtil.CHARSET_UTF_8;
  } else if (StrUtil.containsIgnoreCase(charsetInContentStr, "gbk")) {
    charsetInContent = CharsetUtil.CHARSET_GBK;

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 查找指定字符串是否包含指定字符串列表中的任意一个字符串,如果包含返回找到的第一个字符串<br>
 * 忽略大小写
 * 
 * @param str 指定字符串
 * @param testStrs 需要检查的字符串数组
 * @return 被包含的第一个字符串
 * @since 3.2.0
 */
public static String getContainsStrIgnoreCase(CharSequence str, CharSequence... testStrs) {
  if (isEmpty(str) || ArrayUtil.isEmpty(testStrs)) {
    return null;
  }
  for (CharSequence testStr : testStrs) {
    if (containsIgnoreCase(str, testStr)) {
      return testStr.toString();
    }
  }
  return null;
}

代码示例来源:origin: cn.hutool/hutool-db

@Override
protected SqlBuilder wrapPageSql(SqlBuilder find, Page page) {
  if (false == StrUtil.containsIgnoreCase(find.toString(), "order by")) {
    //offset 分页必须要跟在order by后面,没有情况下补充默认排序
    find.append(" order by current_timestamp");
  }
  return find.append(" offset ")
      .append(page.getStartPosition())//
      .append(" row fetch next ")//row和rows同义词
      .append(page.getPageSize())//
      .append(" row only");//
}

代码示例来源:origin: cn.hutool/hutool-all

@Override
protected SqlBuilder wrapPageSql(SqlBuilder find, Page page) {
  if (false == StrUtil.containsIgnoreCase(find.toString(), "order by")) {
    //offset 分页必须要跟在order by后面,没有情况下补充默认排序
    find.append(" order by current_timestamp");
  }
  return find.append(" offset ")
      .append(page.getStartPosition())//
      .append(" row fetch next ")//row和rows同义词
      .append(page.getPageSize())//
      .append(" row only");//
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 读取主体,忽略EOFException异常
 * @param in 输入流
 * @return 自身
 * @throws IORuntimeException IO异常
 */
private void readBody(InputStream in) throws IORuntimeException{
  if(ignoreBody) {
    return;
  }
  
  int contentLength = Convert.toInt(header(Header.CONTENT_LENGTH), 0);
  final FastByteArrayOutputStream out = contentLength > 0 ? new FastByteArrayOutputStream(contentLength) : new FastByteArrayOutputStream();
  try {
    IoUtil.copy(in, out);
  } catch (IORuntimeException e) {
    if(e.getCause() instanceof EOFException || StrUtil.containsIgnoreCase(e.getMessage(), "Premature EOF")) {
      //忽略读取HTTP流中的EOF错误
    }else {
      throw e;
    }
  }
  this.bodyBytes = out.toByteArray();
}

代码示例来源:origin: cn.hutool/hutool-http

/**
 * 读取主体,忽略EOFException异常
 * @param in 输入流
 * @return 自身
 * @throws IORuntimeException IO异常
 */
private void readBody(InputStream in) throws IORuntimeException{
  if(ignoreBody) {
    return;
  }
  
  int contentLength = Convert.toInt(header(Header.CONTENT_LENGTH), 0);
  final FastByteArrayOutputStream out = contentLength > 0 ? new FastByteArrayOutputStream(contentLength) : new FastByteArrayOutputStream();
  try {
    IoUtil.copy(in, out);
  } catch (IORuntimeException e) {
    if(e.getCause() instanceof EOFException || StrUtil.containsIgnoreCase(e.getMessage(), "Premature EOF")) {
      //忽略读取HTTP流中的EOF错误
    }else {
      throw e;
    }
  }
  this.bodyBytes = out.toByteArray();
}

相关文章

微信公众号

最新文章

更多

StrUtil类方法