Java Array to String arrayToString(byte[] arg)

Here you can find the source of arrayToString(byte[] arg)

Description

array To String

License

Open Source License

Declaration

public static final String arrayToString(byte[] arg) 

Method Source Code

//package com.java2s;
/* /*from  ww w  .java2  s . co  m*/
  This file is part of JIV.  
  Copyright (C) 2000, 2001 Chris A. Cocosco (crisco@bic.mni.mcgill.ca)
    
  JIV 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.
    
  JIV 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 JIV; if not, write to the Free Software Foundation, Inc.,
  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, 
  or see http://www.gnu.org/copyleft/gpl.html
*/

public class Main {
    public static final String arrayToString(byte[] arg) {

        StringBuffer s = new StringBuffer(arg.toString());
        s.append(" : ");
        for (int i = 0; i < arg.length; ++i) {
            s.append(arg[i]);
            s.append(" ");
        }
        return s.toString();
    }

    public static final String arrayToString(int[] arg) {

        StringBuffer s = new StringBuffer(arg.toString());
        s.append(" : ");
        for (int i = 0; i < arg.length; ++i) {
            s.append(arg[i]);
            s.append(" ");
        }
        return s.toString();
    }
}

Related

  1. arrayToStr(Object[] arr, char split)
  2. arrayToStr(Object[] arr, char split)
  3. arrayToStr(String[] o)
  4. ArrayToStr(String[] strArr, String seperatedBy)
  5. arrayToStr(String[] strArray)
  6. arrayToString(byte[] array)
  7. arrayToString(byte[] bytes)
  8. arrayToString(byte[] source, int index, short size)
  9. arrayToString(double d[])