集册 Java实例教程 将字节数组编码为十六进制字符串。

将字节数组编码为十六进制字符串。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

386
将字节数组编码为十六进制字符串。

/*

 * LastPod is an application used to publish one's iPod play counts to Last.fm.

 * Copyright (C) 2007  Chris Tilden

 *

 * This program is free software; you can redistribute it and/or

 * modify it under the terms of the GNU General Public License

 * as published by the Free Software Foundation; either version 2

 * of the License, or (at your option) any later version.

 *

 * This program is distributed in the hope that it will be useful,

 * but WITHOUT ANY WARRANTY; without even the implied warranty of

 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

 * GNU General Public License for more details.

 *

 * You should have received a copy of the GNU General Public License

 * along with this program; if not, write to the Free Software

 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

 */

//package com.nowjava;

/* from 
N o w J a v a . c o m - 时  代  Java*/

public class Main {

    /**

     * Encodes a byte array into a hexidecimal String.

     * @param array  The byte array to encode.

     * @return  A heidecimal String representing the byte array.

     */

    public static String hexEncode(byte[] array) {

        StringBuffer sb = new StringBuffer();


        for (int i = 0; i &
展开阅读全文