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


Java CharArrayWriter.append方法代码示例

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


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

示例1: toCharArrayWriter

import java.io.CharArrayWriter; //导入方法依赖的package包/类
public CharArrayWriter toCharArrayWriter(String prefix) {
    CharArrayWriter buffer = new CharArrayWriter(100);

    final char delimiter = DEFAULT_DELIMITER;
    final String replaceDelimiter = DEFAULT_REPLACE_DELIMITER;

    if (prefix != null && !prefix.isEmpty()) {
        buffer.append(prefix);
    }

    buffer.append(replaceDelimiter(userId(), delimiter, replaceDelimiter)).append(delimiter);
    buffer.append(replaceDelimiter(eventType(), delimiter, replaceDelimiter))
            .append(delimiter);
    buffer.append(replaceDelimiter(date(), delimiter, replaceDelimiter)).append(delimiter);
    buffer.append(replaceDelimiter(time(), delimiter, replaceDelimiter)).append(delimiter);
    buffer.append(replaceDelimiter(status(), delimiter, replaceDelimiter)).append(delimiter);
    buffer.append(replaceDelimiter(origination(), delimiter, replaceDelimiter))
            .append(delimiter);
    buffer.append(replaceDelimiter(affectedResource(), delimiter, replaceDelimiter));

    return buffer;
}
 
开发者ID:xipki,项目名称:xitk,代码行数:23,代码来源:PciAuditEvent.java

示例2: readFully

import java.io.CharArrayWriter; //导入方法依赖的package包/类
private static char[] readFully(Reader reader) throws IOException {
    CharArrayWriter baos = new CharArrayWriter();
    int r;

    while ((r = reader.read()) != (-1)) {
        baos.append((char) r);
    }

    return baos.toCharArray();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ModificationResultTest.java

示例3: logEvent0

import java.io.CharArrayWriter; //导入方法依赖的package包/类
@Override
protected void logEvent0(AuditEvent event) {
    if (!initialized) {
        LOG.error("syslog audit not initialized");
        return;
    }

    CharArrayWriter sb = new CharArrayWriter(150);
    if (notEmpty(prefix)) {
        sb.append(prefix);
    }

    AuditStatus status = event.status();
    if (status == null) {
        status = AuditStatus.UNDEFINED;
    }

    sb.append("\tstatus: ").append(status.name());

    long duration = event.duration();
    if (duration >= 0) {
        sb.append("\tduration: ").append(Long.toString(duration));
    }

    List<AuditEventData> eventDataArray = event.eventDatas();
    for (AuditEventData m : eventDataArray) {
        if (duration >= 0 && "duration".equalsIgnoreCase(m.name())) {
            continue;
        }
        sb.append("\t").append(m.name()).append(": ").append(m.value());
    }

    final int n = sb.size();
    if (n > maxMessageLength) {
        LOG.warn("syslog message exceeds the maximal allowed length: {} > {}, ignore it",
                n, maxMessageLength);
        return;
    }

    SyslogMessage sm = new SyslogMessage();
    sm.setFacility(syslog.getDefaultFacility());
    if (notEmpty(localname)) {
        sm.setHostname(localname);
    }
    sm.setAppName(event.applicationName());
    sm.setSeverity(getSeverity(event.level()));

    Date timestamp = event.timestamp();
    if (timestamp != null) {
        sm.setTimestamp(timestamp);
    }

    sm.setMsgId(event.name());
    sm.setMsg(sb);

    try {
        syslog.sendMessage(sm);
    } catch (IOException ex) {
        LOG.error("could not send syslog message: {}", ex.getMessage());
        LOG.debug("could not send syslog message", ex);
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:63,代码来源:SyslogAuditServiceImpl.java


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