本文整理匯總了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);
}
}
示例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");
}
}
}
}
}
示例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());
}
示例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");
}
示例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");
}
示例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());
}
示例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);
}
}
示例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();
}
示例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());
}
示例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);
}
}
示例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();
}
示例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));
}
}
示例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());
}
示例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);
}
}
}
示例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('\"');
}
}