Here you can find the source of bytesToString(byte[] buffer, int index, int length)
Parameter | Description |
---|---|
buffer | The byte array containing the string. |
index | The index for the first byte in the byte array. |
length | The number of bytes that make up the string. |
static public String bytesToString(byte[] buffer, int index, int length)
//package com.java2s; /************************************************************************ * Copyright (c) Crater Dog Technologies(TM). All Rights Reserved. * ************************************************************************ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * * * This code is free software; you can redistribute it and/or modify it * * under the terms of The MIT License (MIT), as published by the Open * * Source Initiative. (See http://opensource.org/licenses/MIT) * ************************************************************************/ public class Main { /**//from ww w.ja va2s . co m * This function converts the bytes in a byte array to its corresponding string value. * * @param buffer The byte array containing the string. * @return The corresponding string value. */ static public String bytesToString(byte[] buffer) { return bytesToString(buffer, 0, buffer.length); } /** * This function converts the bytes in a byte array at the specified index to its * corresponding string value. * * @param buffer The byte array containing the string. * @param index The index for the first byte in the byte array. * @param length The number of bytes that make up the string. * @return The corresponding string value. */ static public String bytesToString(byte[] buffer, int index, int length) { return new String(buffer, index, length); } }