本文整理汇总了Java中org.codehaus.plexus.util.Base64.decodeBase64方法的典型用法代码示例。如果您正苦于以下问题:Java Base64.decodeBase64方法的具体用法?Java Base64.decodeBase64怎么用?Java Base64.decodeBase64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.Base64
的用法示例。
在下文中一共展示了Base64.decodeBase64方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: decode
import org.codehaus.plexus.util.Base64; //导入方法依赖的package包/类
private static String decode(String s) {
return new String(Base64.decodeBase64(s.getBytes()));
}