Search code examples
azureazure-storageazure-blob-storageazure-container-service

Azure Blob Container file download


I need to download CSV file from Azure Storage Account, Are there any ways to download the file(CSV) using java SDK or rest API? what API's need to be used?


Solution

  • You can use the Azure Storage SDK for java . To download a file, you just need to use the class CloudBlockBlob which should look like,

    // Download the blob to a local file
    // Append the string "DOWNLOAD" before the .txt extension so that you can see both files.
    String downloadFileName = fileName.replace(".txt", "DOWNLOAD.txt");
    File downloadedFile = new File(localPath + downloadFileName);
    
    System.out.println("\nDownloading blob to\n\t " + localPath + downloadFileName);
    
    blobClient.downloadToFile(localPath + downloadFileName);