当前位置: 首页>>代码示例>>Java>>正文


Java Writer.append方法代码示例

本文整理汇总了Java中java.io.Writer.append方法的典型用法代码示例。如果您正苦于以下问题:Java Writer.append方法的具体用法?Java Writer.append怎么用?Java Writer.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.Writer的用法示例。


在下文中一共展示了Writer.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doWriteTo

import java.io.Writer; //导入方法依赖的package包/类
private void doWriteTo(Writer writer, String encoding) {
    writeXmlDeclaration(writer, encoding);

    try {
        if (node != null) {
            printNode(node, writer);
        } else if (element != null) {
            printDomNode(element, writer);
        } else if (builder != null) {
            writer.append(TextUtil.toPlatformLineSeparators(stripXmlDeclaration(builder)));
        } else {
            writer.append(TextUtil.toPlatformLineSeparators(stripXmlDeclaration(stringValue)));
        }
    } catch (IOException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:XmlTransformer.java

示例2: writeTo

import java.io.Writer; //导入方法依赖的package包/类
public void writeTo(Writer w) throws IOException {
  if (DEBUG) {
    w.append("stack.name='" + getThreadName() + "' runnable=" + this.runnable + " lines="
        + lines.size());
    w.append("\n");
  }
  boolean first = true;
  for (String line : lines) {
    w.append(line);
    w.append("\n");
    if (first) {
      first = false;
      if (breadcrumbs != null) {
        for (String bline : breadcrumbs) {
          w.append(bline).append("\n");
        }
      }
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:21,代码来源:PluckStacks.java

示例3: writeLine

import java.io.Writer; //导入方法依赖的package包/类
public static void writeLine(final Writer w, final List<String> values, char separators, final char customQuote) throws IOException {

			boolean first = true;

			//default customQuote is empty

			if (separators == ' ') {
				separators = DEFAULT_SEPARATOR;
			}

			final StringBuilder sb = new StringBuilder();
			for (final String value : values) {
				if (!first) {
					sb.append(separators);
				}
				if (customQuote == ' ') {
					sb.append(followCVSformat(value));
				} else {
					sb.append(customQuote).append(followCVSformat(value)).append(customQuote);
				}

				first = false;
			}
			sb.append("\n");
			w.append(sb.toString());
		}
 
开发者ID:orionhealth,项目名称:rlc-analyser,代码行数:27,代码来源:RLCDataExporter.java

示例4: write

import java.io.Writer; //导入方法依赖的package包/类
public void write(Writer writer, int collapsedRange, boolean indent) throws IOException {
  if (indent) {
    writer.append("    ");
  }
  if (collapsedRange == DO_NOT_COLLAPSE) {
    writer.append(inlinedRange.toString());
  } else {
    writer.append(Range.toCollapsedString(collapsedRange));
  }
  writer.append(":");
  signature.write(writer);
  if (originalRange != null) {
    writer.append(':')
        .append(originalRange.toString());
  }
  writer.append(" -> ")
      .append(renamedSignature.name);
  writer.append("\n");
}
 
开发者ID:inferjay,项目名称:r8,代码行数:20,代码来源:MemberNaming.java

示例5: writeCsvRow

import java.io.Writer; //导入方法依赖的package包/类
private static void writeCsvRow(final Writer fw, final String... values) throws IOException {
    for (int i = 0; i < values.length; i++) {
        if (i != 0) {
            fw.append(",");
        }
        String value = values[i];
        if (value.contains("\n") || value.contains("\r")) {
            throw new IllegalStateException("CSV value should not contain newline (limited implementation).");
        }
        if (value.contains(",") || value.contains("\"")) {
            value = '"' + value.replace("\"", "\"\"") + '"';
        }
        fw.append(value);
    }
    fw.append("\r\n");
}
 
开发者ID:voho,项目名称:emojava,代码行数:17,代码来源:Generator.java

示例6: writeLine

import java.io.Writer; //导入方法依赖的package包/类
public static void writeLine(Writer w, List<String> values, String separators, char customQuote)
		throws IOException {

	boolean first = true;

	if (separators == " ") {
		separators = DEFAULT_SEPARATOR;
	}

	StringBuilder sb = new StringBuilder();
	for (String value : values) {
		if (!first) {
			sb.append(separators);
		}
		if (customQuote == ' ') {
			sb.append(followCVSformat(value));
		} else {
			sb.append(customQuote).append(followCVSformat(value)).append(customQuote);
		}

		first = false;
	}
	sb.append("\n");
	w.append(sb.toString());

}
 
开发者ID:CCWI,项目名称:keywordEntityApiRankService,代码行数:27,代码来源:CSVWriter.java

示例7: encode

import java.io.Writer; //导入方法依赖的package包/类
/**
 * Schrijf dit attribuut.
 *
 * @param value waarde
 * @param writer writer om XML mee te schrijven
 * @throws EncodeException bij encodeer foute
 */
@Override
public void encode(final Context context, final T value, final Writer writer) throws EncodeException {
    LOGGER.debug("encode(value={})", value);
    if (value == null) {
        return;
    }

    try {
        writer.append(" ");
        writer.append(getName());
        writer.append("=\"");
        writer.append(converter.encode(context, value));
        writer.append("\"");
    } catch (final IOException e) {
        throw new EncodeException(context.getElementStack(), e);
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:25,代码来源:AttributeChild.java

示例8: test1

import java.io.Writer; //导入方法依赖的package包/类
private void test1() throws IOException {
	// final JsonObject scope = this.getScope();
	final JsonObject x = this.getScope();
	// Map<String, Object> scope = x.getMap();

	final Map<String, Object> scope = this.mappifyJsonObject(x);
	// Map<String, Object> scope = new HashMap<>();
	// scope.put("YesNo", true);
	// scope.put("answer", 42);
	final Mustache m = this.getTemplate();
	final Writer w = this.getWriter();
	w.append(x.encodePrettily());
	m.execute(w, scope);
	w.close();

}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:17,代码来源:JsonExperiments.java

示例9: testAppendMethods

import java.io.Writer; //导入方法依赖的package包/类
public void testAppendMethods() throws IOException {
  StringBuilder builder = new StringBuilder();
  Writer writer = new AppendableWriter(builder);

  writer.append("Hello,");
  writer.append(' ');
  writer.append("The World Wide Web", 4, 9);
  writer.append("!");

  assertEquals("Hello, World!", builder.toString());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:12,代码来源:AppendableWriterTest.java

示例10: write

import java.io.Writer; //导入方法依赖的package包/类
void write(Writer writer, boolean collapseRanges) throws IOException {
  writer.append(originalName);
  writer.append(" -> ");
  writer.append(renamedName);
  writer.append(":\n");
  for (MemberNaming member : members.values()) {
    member.write(writer, collapseRanges, true);
  }
}
 
开发者ID:inferjay,项目名称:r8,代码行数:10,代码来源:ClassNaming.java

示例11: writeFile

import java.io.Writer; //导入方法依赖的package包/类
public static void writeFile(String fileName, String encoding, String content) throws IOException
{
	Writer out = new BufferedWriter(new OutputStreamWriter(
			new FileOutputStream(fileName), encoding));
	out.append(content);
	out.flush();
	out.close();
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:9,代码来源:FileUtility.java

示例12: printTo

import java.io.Writer; //导入方法依赖的package包/类
@Override
public void printTo(Writer out, ReadablePartial partial, Locale locale) throws IOException {
    if (hasMilliSecondPrecision) {
        out.append(String.valueOf(getDateTimeMillis(partial)));
    } else {
        out.append(String.valueOf(getDateTimeMillis(partial) / 1000));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:Joda.java

示例13: writeLine

import java.io.Writer; //导入方法依赖的package包/类
/**
 * Write a single line to CSV File.
 *
 * @param w
 *            Writer to write to
 * @param values
 *            List of values to write
 * @param separators
 *            List of separators
 * @param customQuote
 *            Custom quotation symbol
 * @throws IOException
 *             Exception thrown by writer
 */
public static void writeLine(Writer w,
        List<String> values,
        char separators,
        char customQuote) throws IOException {
    boolean first = true;

    // default customQuote is empty
    if (separators == ' ') {
        separators = DEFAULT_SEPARATOR;
    }

    StringBuilder sb = new StringBuilder();
    for (String value : values) {
        if (!first) {
            sb.append(separators);
        }
        if (customQuote == ' ') {
            sb.append(followCsvFormat(value));
        }
        else {
            sb.append(customQuote).append(followCsvFormat(value)).append(customQuote);
        }

        first = false;
    }
    sb.append("\n");
    w.append(sb.toString());
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:43,代码来源:CsvUtils.java

示例14: addAttributes

import java.io.Writer; //导入方法依赖的package包/类
private void addAttributes(Writer sb) throws IOException {
    if (attributes != null) {
        for (Map.Entry<String, Object> item : attributes.entrySet()) {
            sb.append(SPACE).append(item.getKey()).append(EQUEL).append(
                    QUOT);
            addText(sb, (String)item.getValue());
            sb.append(QUOT);
        }
    }
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:11,代码来源:XmlElement.java

示例15: writeCustomFieldData

import java.io.Writer; //导入方法依赖的package包/类
/**
 * Write all custom field values attached to given issue and custom field. Multi-valued custom fields use ',' as
 * separator.
 */
private void writeCustomFieldData(final int issue, final CustomFieldEditor customField, final Writer writer, final Format df) throws IOException {
	final int customFieldId = customField.getId();

	// Write the custom field data
	boolean first = true;
	moveToIssueAndCustomField(issue, customFieldId);
	boolean stringData = false;
	while (issueAndCustomFieldsCursor < customFieldValues.size() && customFieldValues.get(issueAndCustomFieldsCursor).getIssue() == issue
			&& customFieldValues.get(issueAndCustomFieldsCursor).getCustomField() == customFieldId) {
		// Custom field value has been found
		final CustomFieldValue customFieldValue = customFieldValues.get(issueAndCustomFieldsCursor);
		if (!first) {
			// Multi-valued custom field, append the value
			writer.append(',');
		}
		final Object value = customField.getEditor().getValue(customField, customFieldValue);
		if (value == null) {
			// Broken reference has been found, report it
			writer.append("#INVALID");
			log.warn("Broken reference for project '{}'[{}], issue [{}], custom field '{}'[{}], value '{}'",
					slaComputations.getProject().getName(), slaComputations.getJira(), issue, customField.getName(), customField.getId(),
					customFieldValue.getStringValue());
		} else if (value instanceof Date) {
			// Simple date, no escape
			writer.append(df.format(value));
		} else if (value instanceof Number) {
			// Simple number, no escape
			writer.append(StringUtils.removeEnd(value.toString().replace('.', ','), ",0"));
		} else {
			if (!stringData) {
				// Add the cell protection
				writer.append('\"');
				stringData = true;
			}
			// Write the value escaping the protection chars
			writer.append(value.toString().replace("\"", "\"\"").replace(';', ','));
		}
		issueAndCustomFieldsCursor++;
		first = false;
	}

	// Close the cell protection
	if (stringData) {
		writer.append('\"');
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:51,代码来源:CsvWithCustomFieldsStreamingOutput.java


注:本文中的java.io.Writer.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。