Package java.io

Examples of java.io.DataInputStream.readFully()


        InputStream is = data.getInputStream();
        DataInputStream dis = new DataInputStream(is);
        for(int i=0;i<n;i++) {
            blocks[i] = new byte[BLOCK_SIZE];
            if(i < n-1) {
                dis.readFully(blocks[i]);
            } else {
                int length = (int) (size - i*BLOCK_SIZE);
                dis.readFully(blocks[i], 0, length);
                // Now pad it ...
                blocks[i] = BucketTools.pad(blocks[i], BLOCK_SIZE, length);
View Full Code Here


            blocks[i] = new byte[BLOCK_SIZE];
            if(i < n-1) {
                dis.readFully(blocks[i]);
            } else {
                int length = (int) (size - i*BLOCK_SIZE);
                dis.readFully(blocks[i], 0, length);
                // Now pad it ...
                blocks[i] = BucketTools.pad(blocks[i], BLOCK_SIZE, length);
            }
        }
        return blocks;
View Full Code Here

      File hwrng = new File("/dev/hwrng");
      if(hwrng.exists() && hwrng.canRead())
        try {
          fis = new FileInputStream(hwrng);
          dis = new DataInputStream(fis);
          dis.readFully(buf);
          consumeBytes(buf);
          dis.readFully(buf);
          consumeBytes(buf);
          dis.close();
        } catch(Throwable t) {
View Full Code Here

        try {
          fis = new FileInputStream(hwrng);
          dis = new DataInputStream(fis);
          dis.readFully(buf);
          consumeBytes(buf);
          dis.readFully(buf);
          consumeBytes(buf);
          dis.close();
        } catch(Throwable t) {
          Logger.normal(this, "Can't read /dev/hwrng even though exists and is readable: " + t, t);
        } finally {
View Full Code Here

      // Read some bits from /dev/urandom
      try {
        fis = new FileInputStream("/dev/urandom");
        dis = new DataInputStream(fis);
        dis.readFully(buf);
        consumeBytes(buf);
        dis.readFully(buf);
        consumeBytes(buf);
      } catch(Throwable t) {
        Logger.normal(this, "Can't read /dev/urandom: " + t, t);
View Full Code Here

      try {
        fis = new FileInputStream("/dev/urandom");
        dis = new DataInputStream(fis);
        dis.readFully(buf);
        consumeBytes(buf);
        dis.readFully(buf);
        consumeBytes(buf);
      } catch(Throwable t) {
        Logger.normal(this, "Can't read /dev/urandom: " + t, t);
        // We can't read it; let's skip /dev/random and seed from SecureRandom.generateSeed()
        canBlock = true;
View Full Code Here

      if(canBlock)
        // Read some bits from /dev/random
        try {
          fis = new FileInputStream("/dev/random");
          dis = new DataInputStream(fis);
          dis.readFully(buf);
          consumeBytes(buf);
          dis.readFully(buf);
          consumeBytes(buf);
        } catch(Throwable t) {
          Logger.normal(this, "Can't read /dev/random: " + t, t);
View Full Code Here

        try {
          fis = new FileInputStream("/dev/random");
          dis = new DataInputStream(fis);
          dis.readFully(buf);
          consumeBytes(buf);
          dis.readFully(buf);
          consumeBytes(buf);
        } catch(Throwable t) {
          Logger.normal(this, "Can't read /dev/random: " + t, t);
        } finally {
          Closer.close(dis);
View Full Code Here

            for (int i = 0; i != input.length / 2; i++)
            {
                bytes[i] = (byte)dIn.read();
            }
            dIn.readFully(bytes, input.length / 2, bytes.length - input.length / 2);
        }
        catch (Exception e)
        {
            fail("" + algorithm + " failed decryption - " + e.toString());
        }
View Full Code Here

            for (int i = 0; i != input.length / 2; i++)
            {
                bytes[i] = (byte)dIn.read();
            }
            dIn.readFully(bytes, input.length / 2, bytes.length - input.length / 2);
        }
        catch (Exception e)
        {
            fail(alg + " failed encryption - " + e.toString());
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.