Java Byte Array to String bytesToString(byte[] data, int start, int end)

Here you can find the source of bytesToString(byte[] data, int start, int end)

Description

Converts a byte array to a hex readable string.

License

Apache License

Declaration

public static String bytesToString(byte[] data, int start, int end) 

Method Source Code

//package com.java2s;
// Licensed to the Apache Software Foundation (ASF) under one

public class Main {
    /**//from   ww  w. ja  v a  2  s  .  c  o  m
     * Converts a byte array to a hex readable string.
     **/
    public static String bytesToString(byte[] data, int start, int end) {
        StringBuilder buf = new StringBuilder();
        if (end > data.length) {
            end = data.length;
        }
        for (int i = start; i < end; i++) {
            buf.append(" ");
            buf.append(Integer.toHexString(data[i] & 0xff));
        }
        return buf.toString();
    }
}

Related

  1. bytesToString(byte[] bytes)
  2. bytesToString(byte[] bytes, int offs, int len)
  3. bytesToString(byte[] bytes, int startIndex)
  4. bytesToString(byte[] bytes, String encoding)
  5. bytesToString(byte[] data)
  6. bytesToString(byte[] hasher)
  7. bytesToString(byte[] id)
  8. bytesToString(byte[] input)
  9. bytesToString(byte[] myByte)