当前位置: 首页>>代码示例>>Java>>正文


Java Base64.encode方法代码示例

本文整理汇总了Java中org.apache.xmlbeans.impl.util.Base64.encode方法的典型用法代码示例。如果您正苦于以下问题:Java Base64.encode方法的具体用法?Java Base64.encode怎么用?Java Base64.encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.xmlbeans.impl.util.Base64的用法示例。


在下文中一共展示了Base64.encode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveStorage

import org.apache.xmlbeans.impl.util.Base64; //导入方法依赖的package包/类
public void saveStorage() {
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput output = new ObjectOutputStream(buffer);
        List<StorageAccount> data = StorageAccountRegistry.getStrgList();
        /*
         * Sort list according to storage account name.
*/
        Collections.sort(data);
        StorageAccount[] dataArray = new StorageAccount[data.size()];
        int i = 0;
        for (StorageAccount pd1 : data) {
            dataArray[i] = pd1;
            i++;
        }
        try {
            output.writeObject(dataArray);
        } finally {
            output.close();
        }
        myState.storageAccount = new String(Base64.encode(buffer.toByteArray()));
    } catch (IOException e) {
        log(message("err"), e);
    }
}
 
开发者ID:Microsoft,项目名称:Azure-Toolkit-for-IntelliJ,代码行数:26,代码来源:AzureSettings.java

示例2: saveAppInsights

import org.apache.xmlbeans.impl.util.Base64; //导入方法依赖的package包/类
public void saveAppInsights() {
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput output = new ObjectOutputStream(buffer);
        List<ApplicationInsightsResource> data = ApplicationInsightsResourceRegistry.getAppInsightsResrcList();
        /*
* Sort list according to application insights resource name.
*/
        Collections.sort(data);
        ApplicationInsightsResource[] dataArray = new ApplicationInsightsResource[data.size()];
        int i = 0;
        for (ApplicationInsightsResource pd1 : data) {
            dataArray[i] = pd1;
            i++;
        }
        try {
            output.writeObject(dataArray);
        } finally {
            output.close();
        }
        myState.appInsights = new String(Base64.encode(buffer.toByteArray()));
    } catch (IOException e) {
        log(message("err"), e);
    }
}
 
开发者ID:Microsoft,项目名称:Azure-Toolkit-for-IntelliJ,代码行数:26,代码来源:AzureSettings.java

示例3: savePublishDatas

import org.apache.xmlbeans.impl.util.Base64; //导入方法依赖的package包/类
public void savePublishDatas() {
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput output = new ObjectOutputStream(buffer);
        Collection<PublishData> data = WizardCacheManager.getPublishDatas();
        PublishData[] dataArray = new PublishData[data.size()];
        int i = 0;
        for (PublishData pd1 : data) {
            dataArray[i] = new PublishData();
            dataArray[i++].setPublishProfile(pd1.getPublishProfile());
        }
        try {
            output.writeObject(dataArray);
        } finally {
            output.close();
        }
        myState.publishProfile = new String(Base64.encode(buffer.toByteArray()));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Microsoft,项目名称:Azure-Toolkit-for-IntelliJ,代码行数:22,代码来源:AzureSettings.java

示例4: encode

import org.apache.xmlbeans.impl.util.Base64; //导入方法依赖的package包/类
public static String encode(final String str) {
    byte[] bytes = null;
    try {
        bytes = Base64.encode(str.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return new String(bytes);
}
 
开发者ID:krisjin,项目名称:bscl,代码行数:10,代码来源:Base64Util.java

示例5: putObject

import org.apache.xmlbeans.impl.util.Base64; //导入方法依赖的package包/类
public String putObject(NetAppClient netAppClient, StoredEntityMetaData storedEntityMetadata, InputStream inputStream) throws Exception{
		// Create the request
		DefaultHttpClient httpclient = createHttpClient(netAppClient, true);
		HttpPost httpPost = new HttpPost(new URI(getContainerURI(netAppClient, true)));

		// TODO: support chunks for big files
		byte[] encode = Base64.encode(IOUtils.toByteArray(inputStream));
		String bytes = new String(encode);

		initializeHeaders(httpPost, CDMIHttpHeader.CONTENT_TYPE_CDMI_OBJECT);
		String domainURI = "/cdmi_domains/";
		DnxDocument fileDnx = storedEntityMetadata.getFileDnx();
		String mimetype = fileDnx.getSectionKeyValue(DNXConstants.FILEFORMAT.MIMETYPE);
		String string = "{\"domainURI\":\"" + domainURI
				+ "\",\"mimetype\":\"" + mimetype + "\",\"metadata\":{\"pid\" : \"" + storedEntityMetadata.getEntityPid()
				+ "\"},\"valuetransferencoding\":\"base64\",\"value\":\"" + bytes + "\"}";
		httpPost.setEntity(new StringEntity(string));

		// 1. Create data object
		HttpResponse response = httpclient.execute(httpPost);

		// 2. get object id from the response
		String identifier = getSpecificJSONValue(response, "objectID");

		// 3. update the existing object value in ranges
/*
    FIXME

    !!! If InputStreamEntity will not work - try sending in ranges manually

 		long partSize = 4096;
		long remainingBytes = storedEntityMetadata.getSizeInBytes();
		long currentRange = 0;
		long endRange = 0;
		boolean isLastPart = (remainingBytes - partSize <= 0);
		while (remainingBytes > 0) {
			isLastPart = (remainingBytes - partSize <= 0);
			if(isLastPart){
				partSize = remainingBytes;
			}
			endRange = currentRange+partSize;
			httpput = new HttpPut(getCDMIObjectURI(netAppClient, identifier)+"?value:"+currentRange+":"+endRange);
			byte [] stream = new byte[(int) partSize];
			inputStream.read(stream);
			StringEntity entity = new StringEntity(new String(stream));
			httpput.setEntity(entity);
			response = httpclient.execute(httpput);
			if (!isSuccessfulResponse(response)){
				deleteObject(netAppClient, identifier);
				return null;
			}
			remainingBytes = remainingBytes - partSize;
		}
*/

		return identifier;
	}
 
开发者ID:ExLibrisGroup,项目名称:Rosetta.NetAppStoragePlugin,代码行数:58,代码来源:CDMIConnector.java


注:本文中的org.apache.xmlbeans.impl.util.Base64.encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。