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


Java Buffer.toString方法代码示例

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


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

示例1: parseMetaData

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
/**
 * 解析Buffer为metadata(JsonObject)。
 * 
 * @param buffer buffer
 * @param charset charset
 * @return JsonObject
 */
public static JsonObject parseMetaData(Buffer buffer, String charset) {
	JsonObject json = new JsonObject();

	if (buffer == null || buffer.length() == 0) {
		return json;
	}

	String meta = buffer.toString(charset);

	if (meta == null || meta.isEmpty()) {
		return json;
	}

	String[] md = meta.split(FDFS_RECORD_SEPERATOR);

	for (String item : md) {
		String[] kv = item.split(FDFS_FIELD_SEPERATOR);
		if (kv.length >= 2) {
			json.put(FdfsUtils.fdfsTrim(kv[0]), FdfsUtils.fdfsTrim(kv[1]));
		}
	}

	return json;
}
 
开发者ID:gengteng,项目名称:vertx-fastdfs-client,代码行数:32,代码来源:FdfsProtocol.java

示例2: parseXml

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
private void parseXml(Buffer buffer, Future<Void> future) {
    String xmlFeed = buffer.toString("UTF-8");

    final SAXBuilder sax = new SAXBuilder();

    try {

        Document doc = sax.build(new InputSource(new StringReader(xmlFeed)));
        List<JsonObject> entries = RssUtils.toJson(doc);
        vertx.eventBus().publish((CommonConstants.VERTX_EVENT_BUS_HE_RSS_JDG_PUT), new JsonArray(entries));
        future.complete();

    } catch (JDOMException | IOException e) {
        future.fail(new RuntimeException("Exception caught when building SAX Document", e));
    }
}
 
开发者ID:benemon,项目名称:he-rss-poll,代码行数:17,代码来源:PollingVerticle.java

示例3: replySuccess

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
private void replySuccess(final HttpServerResponse response,
                          final HttpClientResponse clientResponse,
                          final Buffer buffer) {
    final String data = buffer.toString();
    // Copy header
    response.headers().setAll(clientResponse.headers());
    response.setStatusCode(clientResponse.statusCode());
    response.setStatusMessage(clientResponse.statusMessage());
    response.write(data);
    response.end();
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:12,代码来源:ServiceJet.java

示例4: loadPem

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
private static List<byte[]> loadPem(Buffer data, String delimiter) throws IOException {
    String pem = data.toString();
    String beginDelimiter = "-----BEGIN " + delimiter + "-----";
    String endDelimiter = "-----END " + delimiter + "-----";
    List<byte[]> pems = new ArrayList<>();
    int index = 0;
    while (true) {
        index = pem.indexOf(beginDelimiter, index);
        if (index == -1) {
            break;
        }
        index += beginDelimiter.length();
        int end = pem.indexOf(endDelimiter, index);
        if (end == -1) {
            throw new RuntimeException("Missing " + endDelimiter + " delimiter");
        }
        String content = pem.substring(index, end);
        content = content.replaceAll("\\s", "");
        if (content.length() == 0) {
            throw new RuntimeException("Empty pem file");
        }
        index = end + 1;
        pems.add(Base64.getDecoder().decode(content));
    }
    if (pems.isEmpty()) {
        throw new RuntimeException("Missing " + beginDelimiter + " delimiter");
    }
    return pems;
}
 
开发者ID:xkr47,项目名称:vertx-acme4j,代码行数:30,代码来源:PemLoader.java

示例5: parseBitcoinPriceLine

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
/**
 * One line has the format:
 * <pre>
 *     timestamp,price,volume
 * </pre>
 * <ul>
 * <li>timestamp is unix timestamp in seconds</li>
 * <li>price is in USD in double</li>
 * <li>volume is in USD in double</li>
 * </ul>
 *
 * @param bufferedLine
 */
private void parseBitcoinPriceLine(final Buffer bufferedLine) {

    final String line = bufferedLine.toString();
    final int firstDelim = line.indexOf(',');
    final int lastDelim = line.lastIndexOf(',');
    if (firstDelim != -1 && lastDelim != -1 && firstDelim != lastDelim) {
        long timestamp = Long.parseLong(line.substring(0, firstDelim)) * 1000;
        double price = Double.parseDouble(line.substring(firstDelim + 1, lastDelim));
        this.dataset.put(timestamp, price);
    }
}
 
开发者ID:gmuecke,项目名称:grafana-vertx-datasource,代码行数:25,代码来源:BitcoinAdjustedData.java


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