簡體   English   中英

使用Apache Commons進行base64字符串解碼

[英]base64 String decoding using Apache Commons

我正在嘗試從保管箱解碼我的文件之一。 使用此論壇中的帖子之一

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.StringUtils;
String base64String = getFileResults.get_Response();//returns a file content in base64
String result = StringUtils.newStringUtf8(Base64.decodeBase64(base64String));

但是Netbeans不斷告訴我,decodeBase64()不采用字符串,但是API表示它采用以64為底的字符串。

我想念什么?

嘗試Java SE中可用的javax.xml.bind.DatatypeConverter.parseBase64Binary(base64String)

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;

...
File file = new File( "path" );
byte[] bytes = Base64.decodeBase64( "base64" );
FileUtils.writeByteArrayToFile( file, bytes );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM