Java Random Int randomHex(int length)

Here you can find the source of randomHex(int length)

Description

random Hex

License

Open Source License

Declaration

public static String randomHex(int length) 

Method Source Code

//package com.java2s;
/*/*from   w w w .j av a  2  s .c o m*/
 * Copyright (C) 2010 - 2012 Jenia Software.
 *
 * This file is part of Sinekarta
 *
 * Sinekarta 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 3 of the License, or
 * (at your option) any later version.
 *
 * Sinekarta 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.
 *
 */

public class Main {
    public static String randomHex(int length) {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < length; i++) {
            buf.append(Long.toHexString((long) (Math.random() * 16)));
        }
        return buf.toString();
    }
}

Related

  1. randomBytes(int size)
  2. randomCommon(int min, int max, int n)
  3. randomCommonStr(int min, int max, int n)
  4. randomDoubleMatrix(int rows, int columns)
  5. randomFloatInInterval(float lower, float upper)
  6. randomHexOfInt(int min, int max)
  7. randomInIntervall(float low, float high)
  8. randomInt(double arg)
  9. randomInt(final int max)