Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Random;

public class Main {
    /**
     *
     * @param len
     * @return
     */
    public static String getRandomHex(int len) {
        Random r = new Random();
        StringBuffer sb = new StringBuffer();
        while (sb.length() < len) {
            sb.append(Integer.toHexString(r.nextInt()));
        }
        return sb.toString().substring(0, len).toUpperCase();
    }
}