Source:
public static void main(String[] args) throws IOException { String accountName = SampleHelper.getAccountName(); String accountKey = SampleHelper.getAccountKey(); StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); String endpoint = String.format(Locale.ROOT, "<LINK_0>", accountName); DataLakeServiceClient storageClient = new DataLakeServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient(); FileSystemClient fileSystemClient = storageClient.getFileSystemClient("myjavafilesystembasic" + System.currentTimeMillis()); fileSystemClient.create(); DataLakeFileClient fileClient = fileSystemClient.getFileClient("HelloWorld.txt"); String data = "Hello world!"; InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); fileClient.create(); fileClient.append(dataStream, 0, data.length()); fileClient.flush(data.length()); dataStream.close(); int dataSize = (int) fileClient.getProperties().getFileSize(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(dataSize); fileClient.read(outputStream); outputStream.close(); if (!data.equals(new String(outputStream.toByteArray(), StandardCharsets.UTF_8))) { throw new RuntimeException("The downloaded data does not match the uploaded data."); } for (int i = 0; i < 3; i++) { String sampleData = "Samples"; InputStream dataInFiles = new ByteArrayInputStream(sampleData.getBytes(Charset.defaultCharset())); DataLakeFileClient fClient = fileSystemClient.getFileClient("myfilesforlisting" + System.currentTimeMillis()); fClient.create(); fClient.append(dataInFiles, 0, sampleData.length()); fClient.flush(sampleData.length()); dataInFiles.close(); fileSystemClient.getDirectoryClient("mydirsforlisting" + System.currentTimeMillis()).create(); } fileSystemClient.listPaths() .forEach(pathItem -> System.out.println("Path name: " + pathItem.getName())); fileClient.delete(); fileSystemClient.delete(); }

Target:
public static void main(String[] args) throws IOException { String accountName = SampleHelper.getAccountName(); String accountKey = SampleHelper.getAccountKey(); StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey); String endpoint = String.format(Locale.ROOT, "<LINK_0>", accountName); DataLakeServiceClient storageClient = new DataLakeServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient(); DataLakeFileSystemClient dataLakeFileSystemClient = storageClient.getFileSystemClient("myjavafilesystembasic" + System.currentTimeMillis()); dataLakeFileSystemClient.create(); DataLakeFileClient fileClient = dataLakeFileSystemClient.getFileClient("HelloWorld.txt"); String data = "Hello world!"; InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); fileClient.create(); fileClient.append(dataStream, 0, data.length()); fileClient.flush(data.length()); dataStream.close(); int dataSize = (int) fileClient.getProperties().getFileSize(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(dataSize); fileClient.read(outputStream); outputStream.close(); if (!data.equals(new String(outputStream.toByteArray(), StandardCharsets.UTF_8))) { throw new RuntimeException("The downloaded data does not match the uploaded data."); } for (int i = 0; i < 3; i++) { String sampleData = "Samples"; InputStream dataInFiles = new ByteArrayInputStream(sampleData.getBytes(Charset.defaultCharset())); DataLakeFileClient fClient = dataLakeFileSystemClient.getFileClient("myfilesforlisting" + System.currentTimeMillis()); fClient.create(); fClient.append(dataInFiles, 0, sampleData.length()); fClient.flush(sampleData.length()); dataInFiles.close(); dataLakeFileSystemClient.getDirectoryClient("mydirsforlisting" + System.currentTimeMillis()).create(); } dataLakeFileSystemClient.listPaths() .forEach(pathItem -> System.out.println("Path name: " + pathItem.getName())); fileClient.delete(); dataLakeFileSystemClient.delete(); }