Java ByteBuffer to String toString(ByteBuffer b, String separator)

Here you can find the source of toString(ByteBuffer b, String separator)

Description

to String

License

Apache License

Declaration

public static final String toString(ByteBuffer b, String separator) 

Method Source Code


//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.nio.ByteBuffer;

public class Main {
    public static final String toString(ByteBuffer b, String separator) {
        StringBuilder s = new StringBuilder();
        for (int i = b.position(); i < b.limit(); i++) {
            if (i > b.position())
                s.append(separator);//from   w ww  . j a  va  2s  .  c o m
            byte c = b.get(i);
            if (c >= 0)
                s.append(c);
            else
                s.append(256 + c);
        }
        return s.toString();
    }
}

Related

  1. string(ByteBuffer buffer)
  2. string(ByteBuffer buffer)
  3. string(ByteBuffer buffer, int position, int length, Charset charset)
  4. string(ByteBuffer bytes)
  5. toString(@Nonnull ByteBuffer buf, int len)
  6. toString(ByteBuffer bb)
  7. toString(ByteBuffer buf)
  8. toString(ByteBuffer buf, int len)
  9. toString(ByteBuffer buffer)