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

com.github.df.restypass.util.StringBuilderFactory Maven / Gradle / Ivy

The newest version!
package com.github.df.restypass.util;

/**
 * StringBuilder工厂类
 * Created by darrenfu on 17-7-1.
 */
public class StringBuilderFactory {

    public static final StringBuilderFactory DEFAULT = new StringBuilderFactory();

    private final ThreadLocal pool = ThreadLocal.withInitial(() -> new StringBuilder(512));

    /**
     * BEWARE: MUSN'T APPEND TO ITSELF!
     *
     * @return a pooled StringBuilder
     */
    public StringBuilder stringBuilder() {
        StringBuilder sb = pool.get();
        sb.setLength(0);
        return sb;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy