Home > other >  Azure BlobClient downloadToFile() throws java.nio.file.NoSuchFileException
Azure BlobClient downloadToFile() throws java.nio.file.NoSuchFileException

Time:09-28

As the title says, I am getting the java.nio.file.NoSuchFileException when trying to use the downloadToFile method. I read some doc and it says that the way this method works is that if the file exists, it will throw a FileAlradyExistsException which happened to me when I manually created the file. But I find it weird that when the file doesn't exist, it throws the opposite...

        String localPath = "/Download/"; // this is the path within my server
        BlobClient blobClient;
        for (int i = 0; i < files.length; i  ){
            blobClient = container.getBlobClient(files[i]);


            blobClient.downloadToFile(localPath   files[i]);
        }

        System.out.println("Done");

CodePudding user response:

As @Gaurav Mantri mentioned, the folder itself had to be present. So I had to build all the folders and now the files load perfectly.

  • Related