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

io.github.nichetoolkit.rest.util.CommonUtils Maven / Gradle / Ivy

The newest version!
package io.github.nichetoolkit.rest.util;

/**
 * CommonUtils
 * 

The common utils class.

* @author Cyan ([email protected]) * @since Jdk1.8 */ public class CommonUtils { /** * substring *

The substring method.

* @param content {@link java.lang.String}

The content parameter is String type.

* @param limit {@link java.lang.Integer}

The limit parameter is Integer type.

* @return {@link java.lang.String}

The substring return object is String type.

* @see java.lang.String * @see java.lang.Integer */ public static String substring(String content, Integer limit) { if (GeneralUtils.isEmpty(content)) { return null; } String result; String contentTrim = content.replaceAll("\r", "") .replaceAll("\n", "") // .replaceAll(" ", "") .trim(); if (contentTrim.length() > limit) { result = contentTrim.substring(0, limit).concat("..."); } else { result = contentTrim; } return result; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy