本文整理汇总了Java中com.microsoft.azure.storage.blob.BlobOutputStream.close方法的典型用法代码示例。如果您正苦于以下问题:Java BlobOutputStream.close方法的具体用法?Java BlobOutputStream.close怎么用?Java BlobOutputStream.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.microsoft.azure.storage.blob.BlobOutputStream
的用法示例。
在下文中一共展示了BlobOutputStream.close方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: primeRootContainer
import com.microsoft.azure.storage.blob.BlobOutputStream; //导入方法依赖的package包/类
private static CloudBlockBlob primeRootContainer(CloudBlobClient blobClient,
String accountName, String blobName, int fileSize) throws Exception {
// Create a container if it does not exist. The container name
// must be lower case.
CloudBlobContainer container = blobClient.getContainerReference("https://"
+ accountName + "/" + "$root");
container.createIfNotExists();
// Create a blob output stream.
CloudBlockBlob blob = container.getBlockBlobReference(blobName);
BlobOutputStream outputStream = blob.openOutputStream();
outputStream.write(new byte[fileSize]);
outputStream.close();
// Return a reference to the block blob object.
return blob;
}
示例2: outOfBandFolder_uncleMkdirs
import com.microsoft.azure.storage.blob.BlobOutputStream; //导入方法依赖的package包/类
@Test
public void outOfBandFolder_uncleMkdirs() throws Exception {
// NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
String workingDir = "user/"
+ UserGroupInformation.getCurrentUser().getShortUserName() + "/";
CloudBlockBlob blob = testAccount.getBlobReference(workingDir
+ "testFolder1/a/input/file");
BlobOutputStream s = blob.openOutputStream();
s.close();
assertTrue(fs.exists(new Path("testFolder1/a/input/file")));
Path targetFolder = new Path("testFolder1/a/output");
assertTrue(fs.mkdirs(targetFolder));
}
示例3: outOfBandFolder_parentDelete
import com.microsoft.azure.storage.blob.BlobOutputStream; //导入方法依赖的package包/类
@Test
public void outOfBandFolder_parentDelete() throws Exception {
// NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
String workingDir = "user/"
+ UserGroupInformation.getCurrentUser().getShortUserName() + "/";
CloudBlockBlob blob = testAccount.getBlobReference(workingDir
+ "testFolder2/a/input/file");
BlobOutputStream s = blob.openOutputStream();
s.close();
assertTrue(fs.exists(new Path("testFolder2/a/input/file")));
Path targetFolder = new Path("testFolder2/a/input");
assertTrue(fs.delete(targetFolder, true));
}
示例4: outOfBandFolder_siblingCreate
import com.microsoft.azure.storage.blob.BlobOutputStream; //导入方法依赖的package包/类
@Test
public void outOfBandFolder_siblingCreate() throws Exception {
// NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
String workingDir = "user/"
+ UserGroupInformation.getCurrentUser().getShortUserName() + "/";
CloudBlockBlob blob = testAccount.getBlobReference(workingDir
+ "testFolder3/a/input/file");
BlobOutputStream s = blob.openOutputStream();
s.close();
assertTrue(fs.exists(new Path("testFolder3/a/input/file")));
Path targetFile = new Path("testFolder3/a/input/file2");
FSDataOutputStream s2 = fs.create(targetFile);
s2.close();
}
示例5: outOfBandFolder_rename
import com.microsoft.azure.storage.blob.BlobOutputStream; //导入方法依赖的package包/类
@Test
public void outOfBandFolder_rename() throws Exception {
// NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
String workingDir = "user/"
+ UserGroupInformation.getCurrentUser().getShortUserName() + "/";
CloudBlockBlob blob = testAccount.getBlobReference(workingDir
+ "testFolder4/a/input/file");
BlobOutputStream s = blob.openOutputStream();
s.close();
Path srcFilePath = new Path("testFolder4/a/input/file");
assertTrue(fs.exists(srcFilePath));
Path destFilePath = new Path("testFolder4/a/input/file2");
fs.rename(srcFilePath, destFilePath);
}
示例6: outOfBandSingleFile_rename
import com.microsoft.azure.storage.blob.BlobOutputStream; //导入方法依赖的package包/类
@Test
public void outOfBandSingleFile_rename() throws Exception {
//NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/";
CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder5/a/input/file");
BlobOutputStream s = blob.openOutputStream();
s.close();
Path srcFilePath = new Path("testFolder5/a/input/file");
assertTrue(fs.exists(srcFilePath));
Path destFilePath = new Path("testFolder5/file2");
fs.rename(srcFilePath, destFilePath);
}
示例7: testContainerExistAfterDoesNotExist
import com.microsoft.azure.storage.blob.BlobOutputStream; //导入方法依赖的package包/类
@Test
public void testContainerExistAfterDoesNotExist() throws Exception {
testAccount = AzureBlobStorageTestAccount.create("",
EnumSet.noneOf(CreateOptions.class));
assumeNotNull(testAccount);
CloudBlobContainer container = testAccount.getRealContainer();
FileSystem fs = testAccount.getFileSystem();
// Starting off with the container not there
assertFalse(container.exists());
// A list shouldn't create the container and will set file system store
// state to DoesNotExist
try {
fs.listStatus(new Path("/"));
assertTrue("Should've thrown.", false);
} catch (FileNotFoundException ex) {
assertTrue("Unexpected exception: " + ex,
ex.getMessage().contains("does not exist."));
}
assertFalse(container.exists());
// Create a container outside of the WASB FileSystem
container.create();
// Add a file to the container outside of the WASB FileSystem
CloudBlockBlob blob = testAccount.getBlobReference("foo");
BlobOutputStream outputStream = blob.openOutputStream();
outputStream.write(new byte[10]);
outputStream.close();
// Make sure the file is visible
assertTrue(fs.exists(new Path("/foo")));
assertTrue(container.exists());
}
示例8: outOfBandFolder_rootFileDelete
import com.microsoft.azure.storage.blob.BlobOutputStream; //导入方法依赖的package包/类
@Test
public void outOfBandFolder_rootFileDelete() throws Exception {
CloudBlockBlob blob = testAccount.getBlobReference("fileY");
BlobOutputStream s = blob.openOutputStream();
s.close();
assertTrue(fs.exists(new Path("/fileY")));
assertTrue(fs.delete(new Path("/fileY"), true));
}
示例9: outOfBandFolder_firstLevelFolderDelete
import com.microsoft.azure.storage.blob.BlobOutputStream; //导入方法依赖的package包/类
@Test
public void outOfBandFolder_firstLevelFolderDelete() throws Exception {
CloudBlockBlob blob = testAccount.getBlobReference("folderW/file");
BlobOutputStream s = blob.openOutputStream();
s.close();
assertTrue(fs.exists(new Path("/folderW")));
assertTrue(fs.exists(new Path("/folderW/file")));
assertTrue(fs.delete(new Path("/folderW"), true));
}
示例10: outOfBandFolder_rename_rootLevelFiles
import com.microsoft.azure.storage.blob.BlobOutputStream; //导入方法依赖的package包/类
@Test
public void outOfBandFolder_rename_rootLevelFiles() throws Exception {
// NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
CloudBlockBlob blob = testAccount.getBlobReference("fileX");
BlobOutputStream s = blob.openOutputStream();
s.close();
Path srcFilePath = new Path("/fileX");
assertTrue(fs.exists(srcFilePath));
Path destFilePath = new Path("/fileXrename");
fs.rename(srcFilePath, destFilePath);
}
示例11: primePublicContainer
import com.microsoft.azure.storage.blob.BlobOutputStream; //导入方法依赖的package包/类
public static void primePublicContainer(CloudBlobClient blobClient,
String accountName, String containerName, String blobName, int fileSize)
throws Exception {
// Create a container if it does not exist. The container name
// must be lower case.
CloudBlobContainer container = blobClient
.getContainerReference(containerName);
container.createIfNotExists();
// Create a new shared access policy.
SharedAccessBlobPolicy sasPolicy = new SharedAccessBlobPolicy();
// Set READ and WRITE permissions.
//
sasPolicy.setPermissions(EnumSet.of(
SharedAccessBlobPermissions.READ,
SharedAccessBlobPermissions.WRITE,
SharedAccessBlobPermissions.LIST,
SharedAccessBlobPermissions.DELETE));
// Create the container permissions.
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
// Turn public access to the container off.
containerPermissions
.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
// Set the policy using the values set above.
containerPermissions.getSharedAccessPolicies().put("testwasbpolicy",
sasPolicy);
container.uploadPermissions(containerPermissions);
// Create a blob output stream.
CloudBlockBlob blob = container.getBlockBlobReference(blobName);
BlobOutputStream outputStream = blob.openOutputStream();
outputStream.write(new byte[fileSize]);
outputStream.close();
}
示例12: testReadTimeoutIssue
import com.microsoft.azure.storage.blob.BlobOutputStream; //导入方法依赖的package包/类
public void testReadTimeoutIssue() throws URISyntaxException, StorageException, IOException {
// part 1
byte[] buffer = BlobTestHelper.getRandomBuffer(1 * 1024 * 1024);
// set the maximum execution time
BlobRequestOptions options = new BlobRequestOptions();
options.setMaximumExecutionTimeInMs(5000);
CloudBlobClient blobClient = TestHelper.createCloudBlobClient();
CloudBlobContainer container = blobClient.getContainerReference(generateRandomContainerName());
String blobName = "testBlob";
final CloudBlockBlob blockBlobRef = container.getBlockBlobReference(blobName);
blockBlobRef.setStreamWriteSizeInBytes(1 * 1024 * 1024);
ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer);
BlobOutputStream blobOutputStream = null;
try {
container.createIfNotExists();
blobOutputStream = blockBlobRef.openOutputStream(null, options, null);
try {
blobOutputStream.write(inputStream, buffer.length);
} finally {
blobOutputStream.close();
}
assertTrue(blockBlobRef.exists());
} finally {
inputStream.close();
container.deleteIfExists();
}
// part 2
int length2 = 10 * 1024 * 1024;
byte[] uploadBuffer2 = BlobTestHelper.getRandomBuffer(length2);
CloudBlobClient blobClient2 = TestHelper.createCloudBlobClient();
CloudBlobContainer container2 = blobClient2.getContainerReference(generateRandomContainerName());
String blobName2 = "testBlob";
final CloudBlockBlob blockBlobRef2 = container2.getBlockBlobReference(blobName2);
ByteArrayInputStream inputStream2 = new ByteArrayInputStream(uploadBuffer2);
try {
container2.createIfNotExists();
blockBlobRef2.upload(inputStream2, length2);
} finally {
inputStream2.close();
container2.deleteIfExists();
}
}