Java - Base64字符串输入和输出文本 [英] Java - Base64 string in and out of a text
本文介绍了Java - Base64字符串输入和输出文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将一个包含base64编码文本的字符串写入一个文本文件,然后再将这个字符串从文本文件中读回到一个字符串变量。
I need to write string containing base64 encoded text to a text file and then later read that string back from the text file to a string variable.
这样做是因为编码问题没有数据丢失?
How can i do it so that there is no data loss due to encoding issues?
推荐答案
Base64 只是A-Z,a-z,0-9,+和/。所以应该没有编码问题。只要你能够正确编码Ascii。 Base64被发明以表示 7位字符中的字节。
Base64 is only A–Z, a–z, 0–9, + and /. So there should be no encoding problem. As long as you're able to encode Ascii properly. Base64 was invented to represent bytes in 7-bit characters.
要编码和解码,您可以使用 commons编解码器Base64 。
To encode and decode you can use commons codec Base64.
这篇关于Java - Base64字符串输入和输出文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文