Convert binary byte array To String - Android File Input Output

Android examples for File Input Output:Byte Array Convert

Description

Convert binary byte array To String

Demo Code

/*/*from  w  w  w  .  j a va 2  s .  c  o  m*/
 ByteUtil.java
 Copyright (c) 2016 NTT DOCOMO,INC.
 Released under the MIT license
 http://opensource.org/licenses/mit-license.php
 */
//package com.java2s;
import java.io.UnsupportedEncodingException;

public class Main {
    public static String binaryToString(byte[] binary) {
        try {
            return new String(binary, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            return "";
        }
    }
}

Related Tutorials