Buffer buf = new CircularFifoBuffer(4); buf.add("A"); buf.add("B"); buf.add("C"); buf.add("D"); //ABCD buf.add("E"); //BCDE
private static String bodyToString(final Request request){ try { final Request copy = request.newBuilder().build(); final Buffer buffer = new Buffer(); copy.body().writeTo(buffer); return buffer.readUtf8(); } catch (final IOException e) { return "did not work"; } }
private String bodyToString(final RequestBody request) { try { final RequestBody copy = request; final Buffer buffer = new Buffer(); if (copy != null) copy.writeTo(buffer); else return ""; return buffer.readUtf8(); } catch (final IOException e) { return "did not work"; } }
try { final RequestBody copy = request; final Buffer buffer = new Buffer(); if(copy != null) copy.writeTo(buffer);
var crypto = require("crypto"); var testVector = { plaintext : "46303030303030303030303030303030", iv : "", key : "3132333435363738313233343536373831323334353637383132333435363738", ciphertext : "70ab7387a6a94098510bf0a6d972aabe"}; var key = new Buffer(testVector.key, "hex"); var text = new Buffer(testVector.plaintext, "hex"); var cipher = crypto.createCipheriv("aes-256-ecb", key, testVector.iv); var crypted = cipher.update(text,'hex','hex'); crypted += cipher.final("hex"); console.log("> " + crypted); console.log("? " + testVector.ciphertext);
ImageController.create({image: new Buffer(req.body.image, "base64")}, function(err, img) { if(err) { return handleError(res, err); } return res.status(201).json(img); } );
msg_str = "0105A"; //this gives error. Correct version will be something like "0105AB" try { buffer_binary = new Buffer(msg_str, "hex"); // specify hex } catch (err){ // return, callback or whatever else you want to happen } console.log(msg_str); console.log(buffer_binary);
var str = "11afe0bc36d62793bacbe46ef809a3f8de86bfdf1fc901d664c2f740ce51947c"; var charset = "hex"; var buffer = new Buffer(str, charset); var utf8String = buffer.toString(charset); console.log(buffer); console.log(utf8String);
Buffer buf = new CircularFifoBuffer(4); buf.add("A"); buf.add("B"); buf.add("C"); buf.add("D"); //ABCD buf.add("E"); //BCDE
> var i = new Buffer([-1, 255, 3, 4]) undefined > i.readInt8(0) -1 > i.readInt8(1) -1 > i.readUInt8(1) 255 > i.readUInt8(0) 255
client.write(new Buffer([ 0x01, // Ctrl-A 0x32, // 2 0x30, // 0 0x30, // 0 // uncomment if necessary // 0x0d, // \r // 0x0a, // \n ]));
msg_str = "0102ab00aabb00"; buffer_binary = new Buffer(msg_str, "hex"); // specify hex console.log(msg_str); // logs 0102ab00aabb00 console.log(buffer_binary); // logs <Buffer 01 02 ab 00 aa bb 00>
Buffer b = new Buffer(); b.writeUtf8("whatever the hell I want in this file"); // can also write bytes or anything else int actualValue = getRelevantLinesOfFiles(Arrays.asList(b));
var key = "VEhJUyBJUyBBIFNUUklORw=="; //var key = "JOLDQW5wVIdwvHbhSDCktxhfwpgtxlAH+DG5EPoeDT8aPGSDYYh5U6QjbASUhvztjGPgA/Ue2x8QKwUklX7+Xw=="; var secret = new Buffer(key, "base64").toString(); var message = "message"; var crypto = require("crypto"); var hmac = new crypto.createHmac("sha512", secret); var signature = hmac.update(message).digest("base64"); console.log(signature);
public static void main(String args[]) { Buffer oval = new Buffer(); oval.setBackground(Color.RED); JFrame frame=new JFrame(); frame.add( oval ); frame.setSize(500,500); frame.setVisible(true); }
private static String bodyToString(final RequestBody request){ try { final RequestBody copy = request; final Buffer buffer = new Buffer(); copy.writeTo(buffer); return buffer.readUtf8(); } catch (final IOException e) { return "did not work"; } }
public static void main(String[] args){ Buffer buffer = new Buffer(); DisplayThread displayThread = new DisplayThread(buffer); displayThread.start(); }
@Override public RequestBody convert(T value) throws IOException { Buffer buffer = new Buffer(); Writer writer = new OutputStreamWriter(buffer.outputStream(), UTF_8); JsonWriter jsonWriter = gson.newJsonWriter(writer); adapter.write(jsonWriter, value); jsonWriter.close(); TagRequestBody requestBody = TagRequestBody.create(MEDIA_TYPE, buffer.readByteString()); requestBody = value.tag;//just for example ,you will need to check type here return requestBody; }
Buffer b = new Buffer(); // okio.Buffer JsonWriter writer = new JsonWriter(b); //... String jsonString = b.readUtf8();
private static String bodyAsString(RequestBody body) { try { Buffer buffer = new Buffer(); body.writeTo(buffer); return buffer.readString(body.contentType().charset()); } catch (IOException e) { throw new RuntimeException(e); } }