Source:
<code>public static void main(String[] args) throws Exception { String accountName = getAccountName(); String accountKey = getAccountKey(); SharedKeyCredential credential = new SharedKeyCredential(accountName, accountKey); String endpoint = String.format(Locale.ROOT, "<LINK_0>", accountName); StorageClient storageClient = StorageClient.storageClientBuilder().endpoint(endpoint).credential(credential).buildClient(); ContainerClient containerClient = storageClient.getContainerClient("myjavacontainerbasic" + System.currentTimeMillis()); containerClient.create(); BlockBlobClient blobClient = containerClient.getBlockBlobClient("HelloWorld.txt"); String data = "Hello world!"; InputStream dataStream = new ByteArrayInputStream(data.getBytes()); blobClient.upload(dataStream, data.length()); dataStream.close(); <START> OutputStream outputStream = new ByteArrayOutputStream(data.length()); <END> blobClient.download(outputStream); outputStream.close(); if (!data.equals(outputStream.toString())) { throw new RuntimeException("The downloaded data does not match the uploaded data."); } for(int i = 0; i < 3; i++) { String sampleData = "Samples"; InputStream dataInBlobs = new ByteArrayInputStream(sampleData.getBytes(Charset.defaultCharset())); containerClient.getBlockBlobClient("myblobsforlisting" + System.currentTimeMillis()) .upload(dataInBlobs, sampleData.length()); dataInBlobs.close(); } containerClient.listBlobsFlat(new ListBlobsOptions().maxResults(1), null) .forEach(blobItem -> { System.out.println("Blob name: " + blobItem.name() + ", Snapshot: " + blobItem.snapshot()); });; blobClient.delete(); containerClient.delete(); }</code><technical_language>more sense add intermediate sample of blob properties retrieving blobSize BlobProperties set initial stream size? I more common determine this</technical_language>

Target:
public static void main(String[] args) throws Exception { String accountName = getAccountName(); String accountKey = getAccountKey(); SharedKeyCredential credential = new SharedKeyCredential(accountName, accountKey); String endpoint = String.format(Locale.ROOT, "<LINK_0>", accountName); StorageClient storageClient = StorageClient.storageClientBuilder().endpoint(endpoint).credential(credential).buildClient(); ContainerClient containerClient = storageClient.getContainerClient("myjavacontainerbasic" + System.currentTimeMillis()); containerClient.create(); BlockBlobClient blobClient = containerClient.getBlockBlobClient("HelloWorld.txt"); String data = "Hello world!"; InputStream dataStream = new ByteArrayInputStream(data.getBytes()); blobClient.upload(dataStream, data.length()); dataStream.close(); int dataSize = (int) blobClient.getProperties().value().blobSize(); OutputStream outputStream = new ByteArrayOutputStream(dataSize); blobClient.download(outputStream); outputStream.close(); if (!data.equals(outputStream.toString())) { throw new RuntimeException("The downloaded data does not match the uploaded data."); } for(int i = 0; i < 3; i++) { String sampleData = "Samples"; InputStream dataInBlobs = new ByteArrayInputStream(sampleData.getBytes(Charset.defaultCharset())); containerClient.getBlockBlobClient("myblobsforlisting" + System.currentTimeMillis()) .upload(dataInBlobs, sampleData.length()); dataInBlobs.close(); } containerClient.listBlobsFlat() .forEach(blobItem -> { System.out.println("Blob name: " + blobItem.name() + ", Snapshot: " + blobItem.snapshot()); });; blobClient.delete(); containerClient.delete(); }