本文整理汇总了Java中io.vertx.core.streams.WriteStream.write方法的典型用法代码示例。如果您正苦于以下问题:Java WriteStream.write方法的具体用法?Java WriteStream.write怎么用?Java WriteStream.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.streams.WriteStream
的用法示例。
在下文中一共展示了WriteStream.write方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finish
import io.vertx.core.streams.WriteStream; //导入方法依赖的package包/类
@Override
public void finish(WriteStream<Buffer> out) {
// close all parent elements
for (int i = parents.size() - 1; i >= 0; --i) {
XMLStartElement e = parents.get(i);
out.write(Buffer.buffer("</" + e.getName() + ">"));
}
}
示例2: writeHeader
import io.vertx.core.streams.WriteStream; //导入方法依赖的package包/类
/**
* Write the header
* @param out the output stream to write to
*/
private void writeHeader(WriteStream<Buffer> out) {
if (mergedType == FEATURE_COLLECTION) {
out.write(Buffer.buffer("{\"type\":\"FeatureCollection\",\"features\":["));
} else if (mergedType == GEOMETRY_COLLECTION) {
out.write(Buffer.buffer("{\"type\":\"GeometryCollection\",\"geometries\":["));
}
}
示例3: merge
import io.vertx.core.streams.WriteStream; //导入方法依赖的package包/类
@Override
public Observable<Void> merge(ChunkReadStream chunk, GeoJsonChunkMeta meta,
WriteStream<Buffer> out) {
mergeStarted = true;
if (!headerWritten) {
writeHeader(out);
headerWritten = true;
} else {
if (mergedType == FEATURE_COLLECTION || mergedType == GEOMETRY_COLLECTION) {
out.write(Buffer.buffer(","));
} else {
return Observable.error(new IllegalStateException(
"Trying to merge two or more chunks but the merger has only been "
+ "initialized with one chunk."));
}
}
// check if we have to wrap a geometry into a feature
boolean wrap = mergedType == FEATURE_COLLECTION && !"Feature".equals(meta.getType());
if (wrap) {
out.write(Buffer.buffer("{\"type\":\"Feature\",\"geometry\":"));
}
return writeChunk(chunk, meta, out)
.doOnNext(v -> {
if (wrap) {
out.write(Buffer.buffer("}"));
}
});
}
示例4: sendResponse
import io.vertx.core.streams.WriteStream; //导入方法依赖的package包/类
private void sendResponse(Proto.Msg msg, WriteStream<Buffer> sock) {
byte[] bytes = msg.toByteArray();
Buffer response = Buffer.buffer();
response.appendInt(bytes.length);
response.appendBytes(bytes);
sock.write(response);
}
示例5: sendMessageToClient
import io.vertx.core.streams.WriteStream; //导入方法依赖的package包/类
protected void sendMessageToClient(Buffer bytes, WriteStream<Buffer> writer, ReadStream<Buffer> reader) {
try {
writer.write(bytes);
if (writer.writeQueueFull()) {
reader.pause();
writer.drainHandler( done -> reader.resume() );
}
} catch(Throwable e) {
logger.error(e.getMessage());
}
}
示例6: writeFrame
import io.vertx.core.streams.WriteStream; //导入方法依赖的package包/类
public static void writeFrame(JsonObject payload, WriteStream<Buffer> handler) {
// encode
byte[] data = payload.encode().getBytes(UTF8);
handler.write(Buffer.buffer().appendInt(data.length).appendBytes(data));
}
示例7: writeHeader
import io.vertx.core.streams.WriteStream; //导入方法依赖的package包/类
/**
* Write the XML header and the parent elements
* @param out the output stream to write to
*/
private void writeHeader(WriteStream<Buffer> out) {
out.write(Buffer.buffer(XMLHEADER));
parents.forEach(e -> out.write(Buffer.buffer(e.toString())));
}
示例8: finish
import io.vertx.core.streams.WriteStream; //导入方法依赖的package包/类
@Override
public void finish(WriteStream<Buffer> out) {
if (mergedType == FEATURE_COLLECTION || mergedType == GEOMETRY_COLLECTION) {
out.write(Buffer.buffer("]}"));
}
}
示例9: writeTo
import io.vertx.core.streams.WriteStream; //导入方法依赖的package包/类
public void writeTo(WriteStream<Buffer> writeStream) {
writeStream.write(buffer);
}