Package java.io

Examples of java.io.DataInputStream.readFully()


        // In future the flags will tell us whether the database and the datastore are encrypted.
        byte[] clientCacheKey = new byte[32];
        dis.readFully(clientCacheKey);
        byte[] databaseKey = null;
        databaseKey = new byte[32];
        dis.readFully(databaseKey);
        byte[] tempfilesMasterSecret = new byte[64];
        boolean mustWrite = false;
        if(data.length >= 8+32+32+64) {
            dis.readFully(tempfilesMasterSecret);
        } else {
View Full Code Here


        databaseKey = new byte[32];
        dis.readFully(databaseKey);
        byte[] tempfilesMasterSecret = new byte[64];
        boolean mustWrite = false;
        if(data.length >= 8+32+32+64) {
            dis.readFully(tempfilesMasterSecret);
        } else {
                    System.err.println("Created new master secret for encrypted tempfiles");
            hardRandom.nextBytes(tempfilesMasterSecret);
            mustWrite = true;
        }
View Full Code Here

              Logger.error(this, "Manifest is too big: "+size+" bytes, limit is "+MAX_MANIFEST_SIZE);
              break;
            }
            byte[] buf = new byte[(int) size];
            DataInputStream dis = new DataInputStream(zis);
            dis.readFully(buf);
            ByteArrayInputStream bais = new ByteArrayInputStream(buf);
            InputStreamReader isr = new InputStreamReader(bais, "UTF-8");
            BufferedReader br = new BufferedReader(isr);
            String line;
            while((line = br.readLine()) != null) {
View Full Code Here

            Logger.error(NodeUpdater.class, "Manifest is too big: "+size+" bytes, limit is "+MAX_MANIFEST_SIZE);
            break;
          }
          byte[] buf = new byte[(int) size];
          DataInputStream dis = new DataInputStream(zis);
          dis.readFully(buf);
          ByteArrayInputStream bais = new ByteArrayInputStream(buf);
          props.load(bais);
        } else {
            // Read the file. Throw if there is a CRC error.
            // Note that java.util.zip.ZipInputStream only checks the CRC for compressed
View Full Code Here

      // Read byte[]
      DataInputStream is = new DataInputStream(bucket.getInputStream());
      for (int i = 0; i < 16; i++) {
        byte[] buf = new byte[DATA_LONG.length];
        is.readFully(buf);
        assertEquals("Read-Long", new ByteArrayWrapper(DATA_LONG), new ByteArrayWrapper(buf));
      }

      int read = is.read(new byte[1]);
      assertEquals("Read-Long-Size", -1, read);
View Full Code Here

    }

    private void checkBucket(TempBucket bucket, byte[] buf) throws IOException {
        DataInputStream dis = new DataInputStream(bucket.getInputStream());
        byte[] cbuf = new byte[buf.length];
        dis.readFully(cbuf);
        assertTrue(Arrays.equals(buf, cbuf));
    }

    public void testBucketToRAFWhileFile() throws IOException {
        int len = 4095;
View Full Code Here

    }
   
    private static String readPemFile(File f) throws IOException{
        DataInputStream dis = new DataInputStream(new FileInputStream(f));
        byte[] bytes = new byte[(int) f.length()];
        dis.readFully(bytes);
        dis.close();
        return new String(bytes);
    }
   
    /**
 
View Full Code Here

  private byte[] toArray(InputStream inputStream, int size)
      throws IOException {
    byte[] bytes = new byte[size];
        final DataInputStream dis = new DataInputStream(inputStream);
        dis.readFully(bytes);
    return bytes;
  }
}
View Full Code Here

            }

            try {
                byte[] bytes = new byte[(int) file.length()];
                DataInputStream in = new DataInputStream(new FileInputStream(file));
                in.readFully(bytes);
               
                response.setContentLength(bytes.length);
                response.setContentType("text/html");
                response.setStatus(200);
               
View Full Code Here

       
        try {
            File file = new File(path.getFile());
            byte[] bytes = new byte[(int) file.length()];
            DataInputStream in = new DataInputStream(new FileInputStream(file));
            in.readFully(bytes);
           
            response.setContentLength(bytes.length);
            if (file.getName().endsWith(".png")) {
                response.setContentType("image/png");
            } else {
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.