我真的不知道如何恰当地描述这一点。我有一个XML文件,其中包含以下格式的文件(它是jpg文件的一部分):
mF1vmzAUhu8n7T8g307gpNu6bgrpxT6u9lGp3Q/w4JBYA9uynSz59ztA0pKKFFpj+SaKP973PBZg
v/LieleV0Ra04VKkZJ7MSAQikzkXq5T8vvsWX5HIWCZyVkoBKdmDIdfL168Wd3sFJkK1MClZW6s+
UWqyNVTMJFKBwJFC6opZbOoVVSz7y1ZAL2azS5pJYUHY2NYeZLn4AgXblDb6usPulkSJFYk+t/Pq
UinhVa2v+2mvAqqiV7GL65F+jYbSPBIxpUqeMYvjdCvyR2uJD+tIUNnMMWuuzBuccKZCPXK+wEH3
Cx+A5jlEN0zbn6zCWVQpS5UGg7pmbvK0Uw+qLAqeQS6zTYWSpGtWlSfNpGJcHBdxDsaU2PmDGYsv
S7cxn5qs4z2K6UDjh+M5BBfBCd4GJ3gXnOB9cILL4AQfghNcBSf4GJxgPguPEGZXFNKCOZ4Vncbk
NB3vIaY1hhi5sUeqk+bkXCfuQ2S19kZLZXyc8Y3xEMGWwz8vBPfGQwQWkyO0v+4Po7EZrMj+lHBr
9yVMvuqO9aiP9Tvb48ty+GTbhp/vtvV+KZOffOPG5CfxuDH5yUBuTH5SkRuTn5zkxuQnObkx+clS
bkx+0pUbk6e85QgVcifvnKrum/e4U/WhovvWPKpiEwFv28z78N9P0mysXwY0+eE5DgjVTf6imdTw
fITjdVetjhUagbb86VRzXxGtndcM9U1aDnlPbdrcQC7/AwAA//8DAFBLAwQUAAYACAAAACEA82vR
hfEAAABRAgAACwAIAl9yZWxzLy5yZWxzIKIEAiigAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKySz0oDMRCH74LvEObenW0FEWm2FxF6E1kf
YEhm/+BuMiSjtG9vFEQXaunBYya/+fLNkO3uME/mnVMeY7CwrmowHFz0Y+gtvLSPqzswWSl4mmJg
这是什么"格式"叫(我需要谷歌正确)?我试图将这个文本复制到一个文本文件中并命名为#34; MyPicture.jpg",但我无法打开它。是不是可以检索这样的文件?我是否必须更改编码?
在下一步中,我想使用java的StreamWriter来恢复文件。通过这样做,我必须要照顾什么?
答案 0 :(得分:1)
最有可能是base64内容,请尝试这样做并确保将所有数据复制到base64Content
变量中......
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
String base64Content = "mF1vmzAUhu8n7T8g307gpNu6bgrpxT6u9lGp3Q/w4JBYA9uynSz5 ... ";
String decodedContent = IOUtils.toString(Base64.decodeBase64(base64Content.getBytes()), "UTF-8");
如果decodedContent
不可读,您可能有二进制文件(例如MS Word,图像等)。通常查看二进制文件,您可以知道它是什么。如果不使用Apache Tika
将数据写回时,请确保再次使用UTF-8。见how-to-write-a-utf-8-file-with-java