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


Java Base64类代码示例

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


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

示例1: getObjectByRange

import org.apache.xmlbeans.impl.util.Base64; //导入依赖的package包/类
public InputStream getObjectByRange(NetAppClient netAppClient, String identifier, Long start, Long end) throws KeyManagementException, UnrecoverableKeyException, KeyStoreException,
NoSuchAlgorithmException, CertificateException, IOException, URISyntaxException{
	DefaultHttpClient httpclient = createHttpClient(netAppClient, false);
	String range = (start != null && end != null) ? ":" + start + "-" + end : "";
	HttpGet httpget = new HttpGet(new URI(getCDMIObjectURIAsString(netAppClient, identifier) + "?value" + range));
	initializeHeaders(httpget, CDMIHttpHeader.CONTENT_TYPE_CDMI_OBJECT);
	setCredentials(netAppClient, httpclient, false);
	HttpResponse response = httpclient.execute(httpget);
	String value = getSpecificJSONValue(response, "value");
	InputStream content = null;
	if (value != null) {
		byte[] decoded = Base64.decode(value.getBytes());
		content = new ByteArrayInputStream(decoded);
	}
	return content;
}
 
开发者ID:ExLibrisGroup,项目名称:Rosetta.NetAppStoragePlugin,代码行数:17,代码来源:CDMIConnector.java

示例2: loadStorage

import org.apache.xmlbeans.impl.util.Base64; //导入依赖的package包/类
public void loadStorage() {
    try {
        if (myState.storageAccount != null) {
            byte[] data = Base64.decode(myState.storageAccount.getBytes());
            ByteArrayInputStream buffer = new ByteArrayInputStream(data);
            ObjectInput input = new ObjectInputStream(buffer);
            try {
                StorageAccount[] storageAccs = (StorageAccount[]) input.readObject();
                for (StorageAccount str : storageAccs) {
                    if (!StorageAccountRegistry.getStrgList().contains(str)) {
                        StorageAccountRegistry.getStrgList().add(str);
                    }
                }
            } finally {
                input.close();
            }
        }
    } catch (ClassNotFoundException ex) {
        // ignore - this happens because class package changed and settings were not updated
    } catch (Exception e) {
        log(message("err"), e);
    }
}
 
开发者ID:Microsoft,项目名称:Azure-Toolkit-for-IntelliJ,代码行数:24,代码来源:AzureSettings.java

示例3: loadAppInsights

import org.apache.xmlbeans.impl.util.Base64; //导入依赖的package包/类
public void loadAppInsights() {
    try {
        if (myState.appInsights != null) {
            byte[] data = Base64.decode(myState.appInsights.getBytes());
            ByteArrayInputStream buffer = new ByteArrayInputStream(data);
            ObjectInput input = new ObjectInputStream(buffer);
            try {
                ApplicationInsightsResource[] resources = (ApplicationInsightsResource[]) input.readObject();
                for (ApplicationInsightsResource resource : resources) {
                    if (!ApplicationInsightsResourceRegistry.getAppInsightsResrcList().contains(resource)) {
                        ApplicationInsightsResourceRegistry.getAppInsightsResrcList().add(resource);
                    }
                }
            } finally {
                input.close();
            }
        }
    } catch (ClassNotFoundException ex) {
        // ignore - this happens because class package changed and settings were not updated
    } catch (Exception e) {
        log(message("err"), e);
    }
}
 
开发者ID:Microsoft,项目名称:Azure-Toolkit-for-IntelliJ,代码行数:24,代码来源:AzureSettings.java

示例4: 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

示例5: 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

示例6: 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

示例7: sendDocument

import org.apache.xmlbeans.impl.util.Base64; //导入依赖的package包/类
public SendDocumentResponseType sendDocument(String uniqueId, String type, byte[] manus)
    throws XRoadServiceConsumptionException {
  SendDocumentRequestType kassaReq = SendDocumentRequestType.Factory.newInstance();

  kassaReq.setUniqueId(uniqueId);
  kassaReq.setType(type);
  kassaReq.setManus("".getBytes());

  List<XRoadAttachment> attachments = new ArrayList<XRoadAttachment>();
  attachments.add(new XRoadAttachment("manus", "application/octet-stream", Base64.encode(manus)));

  XRoadMessage<SendDocumentResponseType> response =
      send(new XmlBeansXRoadMessage<SendDocumentRequestType>(kassaReq, attachments),
           SEND_DOCUMENT,
           VERSION,
           new RmvikiCallback(),
           null);
  return response.getContent();
}
 
开发者ID:nortal,项目名称:j-road,代码行数:20,代码来源:TreasuryXTeeServiceImpl.java

示例8: sendDocument

import org.apache.xmlbeans.impl.util.Base64; //导入依赖的package包/类
public String sendDocument(String uniqueId, String type, byte[] manus) throws XRoadServiceConsumptionException {
  SendDocumentRequestType kassaReq = SendDocumentRequestType.Factory.newInstance();

  kassaReq.setUniqueId(uniqueId);
  kassaReq.setType(type);

  List<XRoadAttachment> attachments = new ArrayList<XRoadAttachment>();
  attachments.add(new XRoadAttachment("manus", "application/octet-stream", Base64.encode(manus)));

  XRoadMessage<SendDocumentResponseType> response =
      send(new XmlBeansXRoadMessage<SendDocumentRequestType>(kassaReq, attachments),
           SEND_DOCUMENT,
           VERSION,
           new RmvikiCallback(),
           null);

  if (response.getContent().getCode() != 0) {
    return response.getContent().getMessage();
  }
  return null;
}
 
开发者ID:nortal,项目名称:j-road,代码行数:22,代码来源:RmvikiXTeeServiceImpl.java

示例9: 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

示例10: decode

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

示例11: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。