當前位置: 首頁>>代碼示例>>Java>>正文


Java StringJoiner.add方法代碼示例

本文整理匯總了Java中java.util.StringJoiner.add方法的典型用法代碼示例。如果您正苦於以下問題:Java StringJoiner.add方法的具體用法?Java StringJoiner.add怎麽用?Java StringJoiner.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.StringJoiner的用法示例。


在下文中一共展示了StringJoiner.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: asString

import java.util.StringJoiner; //導入方法依賴的package包/類
public String asString() {
    StringJoiner resultLineJointer = new StringJoiner("\n");
    resultLineJointer.add("public static final class " + className + " {");
    resultLineJointer.add("\tprivate final " + classType + " " + nameValue + ";");
    resultLineJointer.add("\tpublic " + classType + " get() {");
    resultLineJointer.add("\t\treturn " + nameValue + ";");
    resultLineJointer.add("\t}");
    resultLineJointer.add("\tpublic " + className + "(" + classType + " " + nameValue + ") {");
    resultLineJointer.add("\t\tthis." + nameValue + " = " + nameValue + ";");
    resultLineJointer.add("\t}");
    resultLineJointer.add(createToString());
    resultLineJointer.add(createOfMethode());
    resultLineJointer.add(createEqualsAndHash());
    resultLineJointer.add("}");
    String s = resultLineJointer.toString();
    return s;
}
 
開發者ID:Ingwersaft,項目名稱:ValueClassGenerator,代碼行數:18,代碼來源:ValueSubClass.java

示例2: getFileContents

import java.util.StringJoiner; //導入方法依賴的package包/類
/**
 * Reads a file into a single string, preserving line breaks.
 * <p>
 * All line breaks will be replaced with the newline character (\n) regardless of
 * whether or not the file uses windows convention or not (\n\r)
 * 
 * @param path
 *            Path to the file that will be read
 * @return The contents of the specified file, as a String
 */
private static String getFileContents(Path path)
{
	try
	{
		List<String> fileLines = Files.readAllLines(path);
		StringJoiner fileJoiner = new StringJoiner("\n");
		
		for (String line : fileLines)
			fileJoiner.add(line);
		
		return fileJoiner.toString();
	}
	catch (Exception e)
	{
		e.printStackTrace();
		return null;
	}
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:29,代碼來源:AssembleConsole.java

示例3: toString

import java.util.StringJoiner; //導入方法依賴的package包/類
public String toString() {
    StringBuilder sb = new StringBuilder();

    if (ownerType != null) {
        sb.append(ownerType.getTypeName());

        sb.append("$");

        if (ownerType instanceof ParameterizedTypeImpl) {
            // Find simple name of nested type by removing the
            // shared prefix with owner.
            sb.append(rawType.getName().replace( ((ParameterizedTypeImpl)ownerType).rawType.getName() + "$",
                                     ""));
        } else
           sb.append(rawType.getSimpleName());
    } else
        sb.append(rawType.getName());

    if (actualTypeArguments != null) {
        StringJoiner sj = new StringJoiner(", ", "<", ">");
        sj.setEmptyValue("");
        for(Type t: actualTypeArguments) {
            sj.add(t.getTypeName());
        }
        sb.append(sj.toString());
    }

    return sb.toString();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:30,代碼來源:ParameterizedTypeImpl.java

示例4: join

import java.util.StringJoiner; //導入方法依賴的package包/類
/**
 * java 8 新增方法 String join(CharSequence delimiter, Iterable<? extends CharSequence> elements)
 * @param delimiter
 * @param elements
 * @return
 */
public static String join(CharSequence delimiter,
                          Iterable<? extends CharSequence> elements) {
    Objects.requireNonNull(delimiter);
    Objects.requireNonNull(elements);
    StringJoiner joiner = new StringJoiner(delimiter);
    for (CharSequence cs: elements) {
        joiner.add(cs);
    }
    return joiner.toString();
}
 
開發者ID:laidu,項目名稱:java-learn,代碼行數:17,代碼來源:StringPartMethod.java

示例5: toString

import java.util.StringJoiner; //導入方法依賴的package包/類
@Override
public String toString() {
    StringJoiner result = new StringJoiner(System.lineSeparator());

    result.add(Arrays.toString(columnNames));

    for (Object[] objects : tuples) {
        result.add(Arrays.stream(objects).map(String::valueOf).collect(
            Collectors.joining(", ")));
    }

    return result.toString() + getExecutionTimeString();
}
 
開發者ID:graphflow,項目名稱:graphflow,代碼行數:14,代碼來源:Tuples.java

示例6: toShortString

import java.util.StringJoiner; //導入方法依賴的package包/類
@Override
String toShortString() {
    StringBuilder sb = new StringBuilder("method ");
    sb.append(getDeclaringClass().getTypeName()).append('.');
    sb.append(getName());
    sb.append('(');
    StringJoiner sj = new StringJoiner(",");
    for (Class<?> parameterType : getParameterTypes()) {
        sj.add(parameterType.getTypeName());
    }
    sb.append(sj);
    sb.append(')');
    return sb.toString();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:Method.java

示例7: SaslPeer

import java.util.StringJoiner; //導入方法依賴的package包/類
SaslPeer(String host, String mechanism, String authId, String... qops) {
    this.host = host;
    this.mechanism = mechanism;

    StringJoiner sj = new StringJoiner(",");
    for (String q : qops) {
        sj.add(q);
    }
    qop = sj.toString();

    callback = new TestCallbackHandler(USER_ID, PASSWD, host, authId);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:ClientServerTest.java

示例8: toString

import java.util.StringJoiner; //導入方法依賴的package包/類
@Override
public String toString() {
    StringJoiner sj = new StringJoiner("\n", "policy: ", "");
    Enumeration<Permission> perms = permissions.elements();
    while (perms.hasMoreElements()) {
        sj.add(perms.nextElement().toString());
    }
    return sj.toString();

}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:TestPolicy.java

示例9: getUsageTexts

import java.util.StringJoiner; //導入方法依賴的package包/類
private String getUsageTexts(DiscordBot bot, String prefix) {
    StringJoiner joiner = new StringJoiner("\n");
    HashMap<String, Command> commandList = bot.getCommands();

    for (Command command: commandList.values()) {
        joiner.add(DiscordUtils.getUsageString(prefix, command.getUsages()));
    }

    return joiner.toString();
}
 
開發者ID:Samoxive,項目名稱:SafetyJim,代碼行數:11,代碼來源:Help.java

示例10: getFile

import java.util.StringJoiner; //導入方法依賴的package包/類
public static String getFile(Path path)
        throws IOException
{
    String line;
    StringJoiner stringJoiner = new StringJoiner("\n");
    try (BufferedReader bufferedReader = new BufferedReader(new FileReader(path.toString()))) {
        while ((line = bufferedReader.readLine()) != null) {
            stringJoiner.add(line);
        }
    }
    return stringJoiner.toString();
}
 
開發者ID:prestodb,項目名稱:presto-manager,代碼行數:13,代碼來源:AgentFileUtils.java

示例11: toString

import java.util.StringJoiner; //導入方法依賴的package包/類
public String toString() {
    if (assertion.length == 1) {
        return assertion[0].toString();
    }

    StringJoiner sj = new StringJoiner(" + ");
    for (int i = 0; i < assertion.length; i++) {
        sj.add(assertion[i].toString());
    }
    return sj.toString();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:RDN.java

示例12: toString

import java.util.StringJoiner; //導入方法依賴的package包/類
@Override
public String toString() {
    String causeString = "Origin[";
    StringJoiner joiner = new StringJoiner(", ");
    for (int i = 0; i < this.origin.length; i++) {
        joiner.add("{Name=" + this.names[i] + ", Object={" + this.origin[i].toString() + "}}");
    }
    return causeString + joiner.toString() + "]";
}
 
開發者ID:ichorpowered,項目名稱:guardianapi,代碼行數:10,代碼來源:Origin.java

示例13: setSelectedExchangeCurrencyPairs

import java.util.StringJoiner; //導入方法依賴的package包/類
@Transient
public void setSelectedExchangeCurrencyPairs(Set<SelectedExchangeCurrencyPair> selectedExchangeCurrencyPairs) {
    this.selectedExchangeCurrencyPairs = selectedExchangeCurrencyPairs;
    for (SelectedExchangeCurrencyPair selectedExchangeCurrencyPair : selectedExchangeCurrencyPairs) {
        StringJoiner stringJoiner = new StringJoiner(",");
        for (CurrencyPair currencyPair : selectedExchangeCurrencyPair.getCurrencyPairList()) {
            stringJoiner.add(currencyPair.toString());
        }
        if (StringUtils.isNotBlank(stringJoiner.toString())) {
            currencyPairByExchangeMap.put(selectedExchangeCurrencyPair.getExchangeName(), stringJoiner.toString());
        }
    }
}
 
開發者ID:semihunaldi,項目名稱:IdeaCurrency,代碼行數:14,代碼來源:IdeaCurrencyConfig.java

示例14: getTraceString

import java.util.StringJoiner; //導入方法依賴的package包/類
public static String getTraceString(StackTraceElement[] stackTraceElements)
{
	final StringJoiner sj = new StringJoiner(Config.EOL);
	for (StackTraceElement stackTraceElement : stackTraceElements)
	{
		sj.add(stackTraceElement.toString());
	}
	return sj.toString();
}
 
開發者ID:rubenswagner,項目名稱:L2J-Global,代碼行數:10,代碼來源:CommonUtil.java

示例15: toString

import java.util.StringJoiner; //導入方法依賴的package包/類
@Override
public String toString() {
    final StringJoiner sj = new StringJoiner(", ", "{ ", " }");
    sj.add("seqNo = "      + Objects.toString(getSeqNo()));
    sj.add("version = "    + Objects.toString(getVersion()));
    sj.add("type = "       + Objects.toString(getType()));
    sj.add("bookingId = "  + Objects.toString(getBookingId()));
    sj.add("userId = "     + Objects.toString(getUserId()));
    sj.add("resourceId = " + Objects.toString(getResourceId()));
    sj.add("bookFrom = "   + Objects.toString(OptionalUtil.unwrap(getBookFrom())));
    sj.add("bookTo = "     + Objects.toString(OptionalUtil.unwrap(getBookTo())));
    return "BookingEventImpl " + sj.toString();
}
 
開發者ID:speedment,項目名稱:eventsourcing-examples,代碼行數:14,代碼來源:GeneratedBookingEventImpl.java


注:本文中的java.util.StringJoiner.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。