本文整理汇总了Java中io.vertx.core.buffer.Buffer.appendBytes方法的典型用法代码示例。如果您正苦于以下问题:Java Buffer.appendBytes方法的具体用法?Java Buffer.appendBytes怎么用?Java Buffer.appendBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.buffer.Buffer
的用法示例。
在下文中一共展示了Buffer.appendBytes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inputStreamToBuffer
import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
private Buffer inputStreamToBuffer(InputStream input) throws IOException {
byte[] data = new byte[1024];
Buffer buffer = Buffer.buffer();
while (((input.read(data, 0, data.length))) != -1) {
buffer.appendBytes(data);
}
return buffer;
}
示例2: inputStreamToBuffer
import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
private static Buffer inputStreamToBuffer(InputStream input) throws IOException {
byte[] data = new byte[1024];
Buffer buffer = Buffer.buffer();
while (((input.read(data, 0, data.length))) != -1) {
buffer.appendBytes(data);
}
return buffer;
}
示例3: toBuffer
import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
/**
* Pumps the contents of an {@link InputStream} to a {@link Buffer}.
*
* @param is
* input stream
* @return buffer
*/
public static Buffer toBuffer(final InputStream is) throws IOException {
final Buffer b = Buffer.buffer(1024);
final byte[] buf = new byte[1024];
int len;
while ((len = is.read(buf)) >= 0) {
b.appendBytes(buf, 0, len);
}
return b;
}
示例4: bufferFromClasspathResource
import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
public static Buffer bufferFromClasspathResource(final String path) {
final Buffer buffer = Buffer.buffer();
try (final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(path)) {
final byte[] buf = new byte[1024];
int nRead;
while ((nRead = is.read(buf, 0, buf.length)) != -1) {
buffer.appendBytes(buf, 0, nRead);
}
return buffer;
} catch (final IOException e) {
throw new UncheckedIOException(e);
}
}
示例5: encodeToWire
import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
@Override
public void encodeToWire(final Buffer buffer,
final Envelop message) {
buffer.appendBytes(Stream.to(message));
}