本文整理了Java中java.util.Base64.getMimeEncoder()
方法的一些代码示例,展示了Base64.getMimeEncoder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.getMimeEncoder()
方法的具体详情如下:
包路径:java.util.Base64
类名称:Base64
方法名:getMimeEncoder
暂无
代码示例来源:origin: prestodb/presto
private static String encodePem(String type, byte[] encoded)
{
return "-----BEGIN " + type + "-----\n" +
getMimeEncoder(64, new byte[] {'\n'}).encodeToString(encoded) + '\n' +
"-----END " + type + "-----\n";
}
}
代码示例来源:origin: prestodb/presto
public String getPemEncoded()
{
return "-----BEGIN CERTIFICATE REQUEST-----\n" +
getMimeEncoder(64, new byte[] {'\n'}).encodeToString(encoded) + '\n' +
"-----END CERTIFICATE REQUEST-----\n";
}
代码示例来源:origin: prestodb/presto
throws Exception
byte[] sharedSecret = Base64.getMimeEncoder().encode("test secret".getBytes(US_ASCII));
sharedSecretFile = Files.createTempFile("secret", "txt");
Files.write(sharedSecretFile, sharedSecret);
代码示例来源:origin: appium/java-client
/**
* Set the clipboard text.
*
* @param text The actual text to be set.
*/
default void setClipboardText(String text) {
setClipboard(ClipboardContentType.PLAINTEXT, Base64
.getMimeEncoder()
.encode(text.getBytes(StandardCharsets.UTF_8)));
}
代码示例来源:origin: appium/java-client
/**
* Set an URL to the clipboard.
*
* @param url the actual URL to set.
*/
default void setClipboardUrl(URL url) {
setClipboard(ClipboardContentType.URL, Base64
.getMimeEncoder()
.encode(checkNotNull(url).toString().getBytes(StandardCharsets.UTF_8)));
}
代码示例来源:origin: appium/java-client
/**
* Set an image to the clipboard.
*
* @param img the actual image to be set.
* @throws IOException if the image cannot be decoded in PNG representation
*/
default void setClipboardImage(BufferedImage img) throws IOException {
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
ImageIO.write(checkNotNull(img), "png", os);
setClipboard(ClipboardContentType.IMAGE, Base64
.getMimeEncoder()
.encode(os.toByteArray()));
}
}
代码示例来源:origin: awslabs/aws-serverless-java-container
public AwsProxyRequestBuilder binaryBody(InputStream is)
throws IOException {
this.request.setIsBase64Encoded(true);
return body(Base64.getMimeEncoder().encodeToString(IOUtils.toByteArray(is)));
}
代码示例来源:origin: airlift/airlift
private static String encodePem(String type, byte[] encoded)
{
return "-----BEGIN " + type + "-----\n" +
getMimeEncoder(64, new byte[] {'\n'}).encodeToString(encoded) + '\n' +
"-----END " + type + "-----\n";
}
}
代码示例来源:origin: com.facebook.presto/presto-jdbc
private static String encodePem(String type, byte[] encoded)
{
return "-----BEGIN " + type + "-----\n" +
getMimeEncoder(64, new byte[] {'\n'}).encodeToString(encoded) + '\n' +
"-----END " + type + "-----\n";
}
}
代码示例来源:origin: airlift/airlift
public String getPemEncoded()
{
return "-----BEGIN CERTIFICATE REQUEST-----\n" +
getMimeEncoder(64, new byte[] {'\n'}).encodeToString(encoded) + '\n' +
"-----END CERTIFICATE REQUEST-----\n";
}
代码示例来源:origin: awslabs/aws-serverless-java-container
public AwsProxyRequestBuilder authorizerPrincipal(String principal) {
if (this.request.getRequestSource() == AwsProxyRequest.RequestSource.API_GATEWAY) {
if (this.request.getRequestContext().getAuthorizer() == null) {
this.request.getRequestContext().setAuthorizer(new ApiGatewayAuthorizerContext());
}
this.request.getRequestContext().getAuthorizer().setPrincipalId(principal);
if (this.request.getRequestContext().getAuthorizer().getClaims() == null) {
this.request.getRequestContext().getAuthorizer().setClaims(new CognitoAuthorizerClaims());
}
this.request.getRequestContext().getAuthorizer().getClaims().setSubject(principal);
}
if (this.request.getRequestSource() == AwsProxyRequest.RequestSource.ALB) {
header("x-amzn-oidc-identity", principal);
try {
header(
"x-amzn-oidc-accesstoken",
Base64.getMimeEncoder().encodeToString(
"test-token".getBytes(ContainerConfig.DEFAULT_CONTENT_CHARSET)
)
);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
return this;
}
代码示例来源:origin: net.dongliu/commons-lang
/**
* Calculate mime base64. Return null if bytes is null.
*/
public static String mimeBase64(byte[] bytes) {
if (bytes == null) {
return null;
}
Base64.Encoder encoder = Base64.getMimeEncoder();
return new String(encoder.encode(bytes));
}
代码示例来源:origin: org.apache.santuario/xmlsec
public static String encodeToString(byte[] bytes) {
if (ignoreLineBreaks) {
return Base64.getEncoder().encodeToString(bytes);
}
return Base64.getMimeEncoder().encodeToString(bytes);
}
代码示例来源:origin: io.appium/java-client
/**
* Set the clipboard text.
*
* @param text The actual text to be set.
*/
default void setClipboardText(String text) {
setClipboard(ClipboardContentType.PLAINTEXT, Base64
.getMimeEncoder()
.encode(text.getBytes(StandardCharsets.UTF_8)));
}
代码示例来源:origin: io.appium/java-client
/**
* Set an URL to the clipboard.
*
* @param url the actual URL to set.
*/
default void setClipboardUrl(URL url) {
setClipboard(ClipboardContentType.URL, Base64
.getMimeEncoder()
.encode(checkNotNull(url).toString().getBytes(StandardCharsets.UTF_8)));
}
代码示例来源:origin: awslabs/aws-serverless-java-container
@Override
public AwsProxyResponse writeResponse(AwsHttpServletResponse containerResponse, Context lambdaContext)
throws InvalidResponseObjectException {
Timer.start("SERVLET_RESPONSE_WRITE");
AwsProxyResponse awsProxyResponse = new AwsProxyResponse();
if (containerResponse.getAwsResponseBodyString() != null) {
String responseString;
if (!isBinary(containerResponse.getContentType()) && isValidUtf8(containerResponse.getAwsResponseBodyBytes())) {
responseString = containerResponse.getAwsResponseBodyString();
} else {
responseString = Base64.getMimeEncoder().encodeToString(containerResponse.getAwsResponseBodyBytes());
awsProxyResponse.setBase64Encoded(true);
}
awsProxyResponse.setBody(responseString);
}
awsProxyResponse.setMultiValueHeaders(containerResponse.getAwsResponseHeaders());
awsProxyResponse.setStatusCode(containerResponse.getStatus());
if (containerResponse.getAwsProxyRequest().getRequestSource() == AwsProxyRequest.RequestSource.ALB) {
awsProxyResponse.setStatusDescription(containerResponse.getStatus() + " " + Response.Status.fromStatusCode(containerResponse.getStatus()).getReasonPhrase());
}
Timer.stop("SERVLET_RESPONSE_WRITE");
return awsProxyResponse;
}
代码示例来源:origin: stackoverflow.com
byte[] bytes = new byte[57];
String enc1 = new sun.misc.BASE64Encoder().encode(bytes);
String enc2 = new String(java.util.Base64.getMimeEncoder().encode(bytes),
StandardCharsets.UTF_8);
System.out.println("enc1 = <" + enc1 + ">");
System.out.println("enc2 = <" + enc2 + ">");
System.out.println(enc1.equals(enc2));
代码示例来源:origin: com.vmware.xenon/xenon-common
private static String createPlainTextResponse() {
Random r = new Random();
byte[] b = new byte[1500];
r.nextBytes(b);
return java.util.Base64.getMimeEncoder().encodeToString(b);
}
代码示例来源:origin: vmware/xenon
private static String createPlainTextResponse() {
Random r = new Random();
byte[] b = new byte[1500];
r.nextBytes(b);
return java.util.Base64.getMimeEncoder().encodeToString(b);
}
代码示例来源:origin: com.vmware.dcp/dcp-common
private static String createPlainTextResponse() {
Random r = new Random();
byte[] b = new byte[1500];
r.nextBytes(b);
return java.util.Base64.getMimeEncoder().encodeToString(b).intern();
}
内容来源于网络,如有侵权,请联系作者删除!