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


Java Base64类代码示例

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


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

示例1: deserialize

import org.codehaus.plexus.util.Base64; //导入依赖的package包/类
@Override
public SolrQuery deserialize(JsonParser parser, DeserializationContext context)
		throws IOException, JsonProcessingException {
	JsonNode node = parser.getCodec().readTree(parser);
	String serialization = node.get(SERIALIZATION).textValue();
	return SerializationUtils.deserialize(Base64.decodeBase64(serialization.getBytes()));
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:8,代码来源:SolrQueryDeserializer.java

示例2: saveImageEmbeddingToFileAndGetFilename

import org.codehaus.plexus.util.Base64; //导入依赖的package包/类
/**
 * Saves image attachments to a file and returns the filename.
 *
 * @param embedding The {@link Embedding} to process.
 * @return The filename to the processed image.
 * @throws CluecumberPluginException The exception if an image cannot be processed.
 */
private String saveImageEmbeddingToFileAndGetFilename(final Embedding embedding) throws CluecumberPluginException {
    if (!embedding.isImage()) {
        return "";
    }

    String fileEnding;
    switch (embedding.getMimeType()) {
        case "image/png":
            fileEnding = ".png";
            break;
        case "image/jpeg":
            fileEnding = ".jpg";
            break;
        case "image/gif":
            fileEnding = ".gif";
            break;
        case "image/svg+xml":
            fileEnding = "svg";
            break;
        default:
            fileEnding = ".unknown";
    }

    byte[] dataBytes = Base64.decodeBase64(embedding.getData().getBytes(StandardCharsets.UTF_8));

    // Clear attachment data to reduce memory
    embedding.setData("");

    String filename = String.format("attachment%03d%s", attachmentIndex, fileEnding);
    try {
        fileIO.writeContentToFile(dataBytes, propertyManager.getGeneratedHtmlReportDirectory() + "/attachments/" + filename);
    } catch (FileCreationException e) {
        logger.error("Could not process image " + filename + " but will continue report generation...");
    }
    return filename;
}
 
开发者ID:trivago,项目名称:cluecumber-report-plugin,代码行数:44,代码来源:ElementPostProcessor.java

示例3: serialize

import org.codehaus.plexus.util.Base64; //导入依赖的package包/类
@Override
public void serialize(SolrQuery value, JsonGenerator generator, SerializerProvider provider) throws IOException {
	generator.writeStartObject();
	generator.writeStringField(SERIALIZATION, new String(Base64.encodeBase64(SerializationUtils.serialize(value))));
	generator.writeEndObject();
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:7,代码来源:SolrQuerySerializer.java

示例4: encode

import org.codehaus.plexus.util.Base64; //导入依赖的package包/类
private static String encode(String s) {
	return new String(Base64.encodeBase64(s.getBytes()));
}
 
开发者ID:strator-dev,项目名称:greenpepper,代码行数:4,代码来源:PHPDriver.java

示例5: decode

import org.codehaus.plexus.util.Base64; //导入依赖的package包/类
private static String decode(String s) {
	return new String(Base64.decodeBase64(s.getBytes()));
}
 
开发者ID:strator-dev,项目名称:greenpepper,代码行数:4,代码来源:PHPDriver.java


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