Here you can find the source of asString(byte[] bs)
Parameter | Description |
---|---|
bs | the bs |
private static String asString(byte[] bs)
//package com.java2s; /*//from ww w . ja v a 2s. com * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Sly Technologies, Inc. * * This file is part of jNetPcap. * * jNetPcap is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * As string. * * @param bs * the bs * @return the string */ private static String asString(byte[] bs) { StringBuilder buf = new StringBuilder(); for (byte b : bs) { if (buf.length() != 0) { buf.append(':'); } if (b >= 0 && b < 16) { buf.append('0'); } buf.append(Integer.toHexString((b < 0) ? b + 256 : b).toUpperCase()); } return buf.toString(); } }