简体   繁体   English

使用Apache Commons进行base64字符串解码

[英]base64 String decoding using Apache Commons

I am trying to decode one of my files from dropbox. 我正在尝试从保管箱解码我的文件之一。 Using one of the post in this forum 使用此论坛中的帖子之一

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));

But the Netbeans keeps telling me that the decodeBase64() does not take string, but the API says that it takes a string in base 64. 但是Netbeans不断告诉我,decodeBase64()不采用字符串,但是API表示它采用以64为底的字符串。

What am i missing? 我想念什么?

尝试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