All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dahuatech.hutool.core.text.ASCIIStrCache Maven / Gradle / Ivy

There is a newer version: 1.0.13.7
Show newest version
package com.dahuatech.hutool.core.text;

/**
 * ASCII字符对应的字符串缓存
 *
 * @author looly
 * @since 4.0.1
 */
public class ASCIIStrCache {

  private static final int ASCII_LENGTH = 128;
  private static final String[] CACHE = new String[ASCII_LENGTH];

  static {
    for (char c = 0; c < ASCII_LENGTH; c++) {
      CACHE[c] = String.valueOf(c);
    }
  }

  /**
   * 字符转为字符串
* 如果为ASCII字符,使用缓存 * * @param c 字符 * @return 字符串 */ public static String toString(char c) { return c < ASCII_LENGTH ? CACHE[c] : String.valueOf(c); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy