本文整理了Java中java.lang.String.concat()
方法的一些代码示例,展示了String.concat()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。String.concat()
方法的具体详情如下:
包路径:java.lang.String
类名称:String
方法名:concat
[英]Concatenates the specified string to the end of this string.
If the length of the argument string is 0
, then this String
object is returned. Otherwise, a new String
object is created, representing a character sequence that is the concatenation of the character sequence represented by this String
object and the character sequence represented by the argument string.
Examples:
"cares".concat("s") returns "caress"
"to".concat("get").concat("her") returns "together"
[中]将指定的字符串连接到此字符串的结尾。
如果参数字符串的长度为0
,则返回此String
对象。否则,将创建一个新的String
对象,该对象表示一个字符序列,该字符序列是此String
对象表示的字符序列与参数字符串表示的字符序列的串联。
示例:
"cares".concat("s") returns "caress"
"to".concat("get").concat("her") returns "together"
代码示例来源:origin: shuzheng/zheng
/**
* 返回jsp视图
* @param path
* @return
*/
public static String jsp(String path) {
return path.concat(".jsp");
}
代码示例来源:origin: square/dagger
/** Returns a key for the members of {@code type}. */
public static String getMembersKey(Class<?> key) {
// for classes key.getName() is equivalent to get(key)
return "members/".concat(key.getName());
}
代码示例来源:origin: shuzheng/zheng
/**
* 返回thymeleaf视图
* @param path
* @return
*/
public static String thymeleaf(String path) {
String folder = PropertiesFileUtil.getInstance().get("app.name");
return "/".concat(folder).concat(path).concat(".html");
}
代码示例来源:origin: androidannotations/androidannotations
public static void assertClassSourcesGeneratedToOutput(Class<?> clazz) {
String canonicalName = clazz.getCanonicalName();
String filePath = canonicalName.replace(".", "/").concat(".java");
File generatedSourcesDir = new File(OUTPUT_DIRECTORY);
File generatedSourceFile = new File(generatedSourcesDir, filePath);
File sourcesDir = new File(MAIN_SOURCE_FOLDER);
File expectedResult = new File(sourcesDir, filePath);
assertOutput(expectedResult, generatedSourceFile);
}
代码示例来源:origin: androidannotations/androidannotations
public static void assertClassSourcesNotGeneratedToOutput(Class<?> clazz) {
String canonicalName = clazz.getCanonicalName();
String filePath = canonicalName.replace(".", "/").concat(".java");
File generatedSourcesDir = new File(OUTPUT_DIRECTORY);
File output = new File(generatedSourcesDir, filePath);
assertFalse(output.exists());
}
代码示例来源:origin: redisson/redisson
/**
* {@inheritDoc}
*/
public String getName() {
return NAME_PREFIX.concat(String.valueOf(getIndex()));
}
代码示例来源:origin: square/dagger
@Override protected ModuleAdapter<?> create(Class<?> type) {
ModuleAdapter<?> result =
instantiate(type.getName().concat(MODULE_ADAPTER_SUFFIX), type.getClassLoader());
if (result == null) {
throw new IllegalStateException("Module adapter for " + type + " could not be loaded. "
+ "Please ensure that code generation was run for this module.");
}
return result;
}
};
代码示例来源:origin: spring-projects/spring-framework
/**
* Find a {@code VersionStrategy} for the request path of the requested resource.
* @return an instance of a {@code VersionStrategy} or null if none matches that request path
*/
@Nullable
protected VersionStrategy getStrategyForPath(String requestPath) {
String path = "/".concat(requestPath);
List<String> matchingPatterns = new ArrayList<>();
for (String pattern : this.versionStrategyMap.keySet()) {
if (this.pathMatcher.match(pattern, path)) {
matchingPatterns.add(pattern);
}
}
if (!matchingPatterns.isEmpty()) {
Comparator<String> comparator = this.pathMatcher.getPatternComparator(path);
matchingPatterns.sort(comparator);
return this.versionStrategyMap.get(matchingPatterns.get(0));
}
return null;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Find a {@code VersionStrategy} for the request path of the requested resource.
* @return an instance of a {@code VersionStrategy} or null if none matches that request path
*/
@Nullable
protected VersionStrategy getStrategyForPath(String requestPath) {
String path = "/".concat(requestPath);
List<String> matchingPatterns = new ArrayList<>();
for (String pattern : this.versionStrategyMap.keySet()) {
if (this.pathMatcher.match(pattern, path)) {
matchingPatterns.add(pattern);
}
}
if (!matchingPatterns.isEmpty()) {
Comparator<String> comparator = this.pathMatcher.getPatternComparator(path);
matchingPatterns.sort(comparator);
return this.versionStrategyMap.get(matchingPatterns.get(0));
}
return null;
}
代码示例来源:origin: hs-web/hsweb-framework
/**
* 转为http查询参数
* @return
*/
default String toHttpQueryParamString() {
Map<String, String> result = new HttpParameterConverter(this).convert();
StringJoiner joiner = new StringJoiner("&");
result.forEach((key, value) -> joiner.add(key.concat("=").concat(value)));
return joiner.toString();
}
}
代码示例来源:origin: macrozheng/mall
@Override
public OssCallbackResult callback(HttpServletRequest request) {
OssCallbackResult result= new OssCallbackResult();
String filename = request.getParameter("filename");
filename = "http://".concat(ALIYUN_OSS_BUCKET_NAME).concat(".").concat(ALIYUN_OSS_ENDPOINT).concat("/").concat(filename);
result.setFilename(filename);
result.setSize(request.getParameter("size"));
result.setMimeType(request.getParameter("mimeType"));
result.setWidth(request.getParameter("width"));
result.setHeight(request.getParameter("height"));
return result;
}
代码示例来源:origin: apache/flink
/**
* Returns a unique, serialized representation for this function.
*/
public final String functionIdentifier() {
final String md5 = EncodingUtils.hex(EncodingUtils.md5(EncodingUtils.encodeObjectToString(this)));
return getClass().getCanonicalName().replace('.', '$').concat("$").concat(md5);
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public String saveStaticFile(InputStream fileStream, String fileName) throws IOException {
//文件后缀
String suffix = fileName.contains(".") ?
fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()) : "";
StorePath path = fastFileStorageClient.uploadFile(fileStream, fileStream.available(), suffix, new HashSet<>());
return staticLocation.concat(path.getFullPath());
}
代码示例来源:origin: hs-web/hsweb-framework
protected String getRealUrl(String url) {
if (url.startsWith("http")) {
return url;
}
if (!serverConfig.getApiBaseUrl().endsWith("/") && !url.startsWith("/")) {
return serverConfig.getApiBaseUrl().concat("/").concat(url);
}
return serverConfig.getApiBaseUrl() + url;
}
代码示例来源:origin: square/dagger
@Override public StaticInjection getStaticInjection(Class<?> injectedClass) {
StaticInjection result = instantiate(
injectedClass.getName().concat(STATIC_INJECTION_SUFFIX), injectedClass.getClassLoader());
if (result != null) {
return result;
}
return ReflectiveStaticInjection.create(injectedClass);
}
}
代码示例来源:origin: hs-web/hsweb-framework
protected String createLockName(String expression) {
try {
if (StringUtils.isEmpty(expression)) {
return interceptorHolder.getMethod().getName().concat("_").concat(interceptorHolder.getId());
}
return ExpressionUtils.analytical(expression, interceptorHolder.getArgs(), "spel");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: xuxueli/xxl-job
private void initI18n(){
for (ExecutorBlockStrategyEnum item:ExecutorBlockStrategyEnum.values()) {
item.setTitle(I18nUtil.getString("jobconf_block_".concat(item.name())));
}
}
代码示例来源:origin: hs-web/hsweb-framework
protected void applyBasicAuthParam(OAuth2Request request) {
request.param(client_id, serverConfig.getClientId());
request.param(client_secret, serverConfig.getClientSecret());
request.param(redirect_uri, serverConfig.getRedirectUri());
request.header(authorization, encodeAuthorization(serverConfig.getClientId().concat(":").concat(serverConfig.getClientSecret())));
}
代码示例来源:origin: apache/kafka
@Override
public ProducerRecord<String, String> onSend(ProducerRecord<String, String> record) {
ONSEND_COUNT.incrementAndGet();
return new ProducerRecord<>(
record.topic(), record.partition(), record.key(), record.value().concat(appendStr));
}
代码示例来源:origin: apache/kafka
@Override
public ProducerRecord<Integer, String> onSend(ProducerRecord<Integer, String> record) {
onSendCount++;
if (throwExceptionOnSend)
throw new KafkaException("Injected exception in AppendProducerInterceptor.onSend");
return new ProducerRecord<>(
record.topic(), record.partition(), record.key(), record.value().concat(appendStr));
}
内容来源于网络,如有侵权,请联系作者删除!