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