Package org.uncommons.maths.random

Examples of org.uncommons.maths.random.SeedException


   * @return A byte array containing the seed data.
   * @throws org.uncommons.maths.random.SeedException
   *          If a seed cannot be generated for any reason.
   */
  public byte[] generateSeed(int length) throws SeedException {
    SeedException savedException = null;
    for (SeedGenerator generator : generators) {
      try {
        return generator.generateSeed(length);
      } catch (SeedException e) {
        if (savedException != null) {
          savedException.initCause(e);
        }
        savedException = e;
      }
    }
    if (savedException != null) {
View Full Code Here


      byte[] randomSeed = new byte[length];
      int count = 0;
      while (count < length) {
        int bytesRead = file.read(randomSeed, count, length - count);
        if (bytesRead == -1) {
          throw new SeedException("EOF encountered reading random data.");
        }
        count += bytesRead;
      }
      return randomSeed;
    } catch (IOException ex) {
      throw new SeedException("Failed reading from " + DEV_URANDOM.getName(), ex);
    } catch (SecurityException ex) {
      // Might be thrown if resource access is restricted (such as in
      // an applet sandbox).
      throw new SeedException("SecurityManager prevented access to " + DEV_URANDOM.getName(), ex);
    } finally {
      if (file != null) {
        try {
          file.close();
        } catch (IOException ex) {
View Full Code Here

    FileInputStream in = null;
    try {
      in = new FileInputStream(DEV_URANDOM);
      return ByteStreams.toByteArray(new LimitInputStream(in, length));
    } catch (IOException ex) {
      throw new SeedException("Failed reading from " + DEV_URANDOM.getName(), ex);
    } catch (SecurityException ex) {
      // Might be thrown if resource access is restricted (such as in
      // an applet sandbox).
      throw new SeedException("SecurityManager prevented access to " + DEV_URANDOM.getName(), ex);
    } finally {
      Closeables.closeQuietly(in);
    }
  }
View Full Code Here

   * @throws org.uncommons.maths.random.SeedException
   *          If a seed cannot be generated for any reason.
   */
  @Override
  public byte[] generateSeed(int length) throws SeedException {
    SeedException savedException = null;
    for (SeedGenerator generator : generators) {
      try {
        return generator.generateSeed(length);
      } catch (SeedException e) {
        if (savedException != null) {
          savedException.initCause(e);
        }
        savedException = e;
      }
    }
    if (savedException != null) {
View Full Code Here

TOP

Related Classes of org.uncommons.maths.random.SeedException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.