Package anlavn.net

Class RandomORG

java.lang.Object
anlavn.net.RandomORG

public class RandomORG extends Object
The RandomORG class supports to create true random numbers from random.org
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final String
    getInteger(int min, int max, int base)
    Use this method to generate truly random integers.
    static final String
    Use this method to examine your quota.
    static final String
    getSequence(int min, int max)
    Use this method to randomize a given interval of integers and arrange them in random order.
    static final String
    getString(int len, boolean digit, boolean upper, boolean lower)
    Use this method to generate truly random strings of various length and character compositions.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RandomORG

      public RandomORG()
  • Method Details

    • getInteger

      public static final String getInteger(int min, int max, int base) throws IOException
      Use this method to generate truly random integers.
      Parameters:
      min - is the smallest value allowed for each integer.
      max - is the largest value allowed for each integer.
      base - is the base that will be used to print the numbers. Decimal is default.
      Example: 2(binary), 8(octal), 10(decimal) or 16(hexadecimal).
      Returns:
      truly random integer.
      Throws:
      IOException - throw an exception if there is no internet connection or cannot connect to random.org
    • getSequence

      public static final String getSequence(int min, int max) throws IOException
      Use this method to randomize a given interval of integers and arrange them in random order.
      Parameters:
      min - is the lower bound of the interval (inclusive).
      max - is the upper bound of the interval (inclusive).
      Returns:
      string with random order.
      Throws:
      IOException - throw an exception if there is no internet connection or cannot connect to random.org
    • getString

      public static final String getString(int len, boolean digit, boolean upper, boolean lower) throws IOException
      Use this method to generate truly random strings of various length and character compositions.
      Parameters:
      len - is the length of the string.
      digit - Determines whether digits (0-9) are allowed to occur in the string.
      upper - Determines whether uppercase alphabetic characters (A-Z) are allowed to occur in the string.
      lower - Determines whether lowercase alphabetic characters (a-z) are allowed to occur in the string.
      Returns:
      truly random string.
      Throws:
      IOException - throw an exception if there is no internet connection or cannot connect to random.org
    • getQuota

      public static final String getQuota() throws IOException
      Use this method to examine your quota. The quota system works on the basis of IP addresses. Each IP address has a base quota of 1,000,000 bits. When your client makes a request for random numbers (or strings, etc.), the server deducts the number of bits it took to satisfy your request from the quota associated with your client's IP address.
      Returns:
      number of quota bits remaining of your IP address.
      Throws:
      IOException - throw an exception if there is no internet connection or cannot connect to random.org