mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-11 08:08:01 +08:00
add test and comment
This commit is contained in:
parent
86479585a8
commit
2ce5b2cc79
@ -196,7 +196,7 @@ public class UploadFile {
|
|||||||
int memoryThreshold = setting.memoryThreshold;
|
int memoryThreshold = setting.memoryThreshold;
|
||||||
if (memoryThreshold > 0) {
|
if (memoryThreshold > 0) {
|
||||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream(memoryThreshold);
|
final ByteArrayOutputStream baos = new ByteArrayOutputStream(memoryThreshold);
|
||||||
int written = input.copy(baos, memoryThreshold);
|
final long written = input.copy(baos, memoryThreshold);
|
||||||
data = baos.toByteArray();
|
data = baos.toByteArray();
|
||||||
if (written <= memoryThreshold) {
|
if (written <= memoryThreshold) {
|
||||||
// 文件存放于内存
|
// 文件存放于内存
|
||||||
|
@ -3604,7 +3604,13 @@ public class CharSequenceUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 替换所有正则匹配的文本,并使用自定义函数决定如何替换
|
* 替换所有正则匹配的文本,并使用自定义函数决定如何替换<br>
|
||||||
|
* replaceFun可以通过{@link Matcher}提取出匹配到的内容的不同部分,然后经过重新处理、组装变成新的内容放回原位。
|
||||||
|
*
|
||||||
|
* <pre class="code">
|
||||||
|
* replaceAll(this.content, "(\\d+)", parameters -> "->" + parameters.group(1) + "<-")
|
||||||
|
* // 结果为:"ZZZaaabbbccc中文->1234<-"
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str 要替换的字符串
|
* @param str 要替换的字符串
|
||||||
* @param pattern 用于匹配的正则式
|
* @param pattern 用于匹配的正则式
|
||||||
|
@ -771,7 +771,13 @@ public class ReUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 替换所有正则匹配的文本,并使用自定义函数决定如何替换
|
* 替换所有正则匹配的文本,并使用自定义函数决定如何替换<br>
|
||||||
|
* replaceFun可以通过{@link Matcher}提取出匹配到的内容的不同部分,然后经过重新处理、组装变成新的内容放回原位。
|
||||||
|
*
|
||||||
|
* <pre class="code">
|
||||||
|
* replaceAll(this.content, "(\\d+)", parameters -> "->" + parameters.group(1) + "<-")
|
||||||
|
* // 结果为:"ZZZaaabbbccc中文->1234<-"
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str 要替换的字符串
|
* @param str 要替换的字符串
|
||||||
* @param regex 用于匹配的正则式
|
* @param regex 用于匹配的正则式
|
||||||
@ -784,7 +790,13 @@ public class ReUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 替换所有正则匹配的文本,并使用自定义函数决定如何替换
|
* 替换所有正则匹配的文本,并使用自定义函数决定如何替换<br>
|
||||||
|
* replaceFun可以通过{@link Matcher}提取出匹配到的内容的不同部分,然后经过重新处理、组装变成新的内容放回原位。
|
||||||
|
*
|
||||||
|
* <pre class="code">
|
||||||
|
* replaceAll(this.content, "(\\d+)", parameters -> "->" + parameters.group(1) + "<-")
|
||||||
|
* // 结果为:"ZZZaaabbbccc中文->1234<-"
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str 要替换的字符串
|
* @param str 要替换的字符串
|
||||||
* @param pattern 用于匹配的正则式
|
* @param pattern 用于匹配的正则式
|
||||||
|
@ -3,10 +3,12 @@ package cn.hutool.core.text;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class CharSequenceUtilTest {
|
public class CharSequenceUtilTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void replace() {
|
public void replaceTest() {
|
||||||
String actual = CharSequenceUtil.replace("SSM15930297701BeryAllen", Pattern.compile("[0-9]"), matcher -> "");
|
String actual = CharSequenceUtil.replace("SSM15930297701BeryAllen", Pattern.compile("[0-9]"), matcher -> "");
|
||||||
Assert.assertEquals("SSMBeryAllen", actual);
|
Assert.assertEquals("SSMBeryAllen", actual);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user