Here you can find the source of asString(byte[] bytes)
Parameter | Description |
---|---|
bytes | the byte array |
public static String asString(byte[] bytes)
//package com.java2s; /**/*w ww. j a va2 s . co m*/ * * jerry - Common Java Functionality * Copyright (c) 2012-2015, Sandeep Gupta * * http://sangupta.com/projects/jerry * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ public class Main { /** * An empty string object containing nothing. */ public static final String EMPTY_STRING = ""; /** * Return the {@link String} representation of the byte array. A * <code>null</code> byte array is converted back to <code>null</code>, an * empty array to an empty string or the bytes to the actual string based on * platform encoding. * * @param bytes * the byte array * * @return its string representation */ public static String asString(byte[] bytes) { if (bytes == null) { return null; } if (bytes.length == 0) { return EMPTY_STRING; } return new String(bytes); } }