Code example for Random

    FileSystem fs = cluster.getFileSystem();
    // Write a file with the specified amount of data 
    DataOutputStream os = fs.create(filepath);
    byte data[] = new byte[1024 * sizeKB];
    new Random().nextBytes(data);
    return data;
   * Get the list of Blocks for a file. 
  public List<LocatedBlock> getFileBlocks(Path filepath, int sizeKB)
      throws IOException { 
    // Return the blocks we just wrote 
    DFSClient dfsclient = getDFSClient();
    return dfsclient.getNamenode().getBlockLocations(
      filepath.toString(), 0, sizeKB * 1024).getLocatedBlocks();
Experience pair programming with AI  Get Codota for Java