當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。