首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java相关 >

.docx文件转base64 再转回.docx文件 乱码有关问题 求帮助

2012-03-21 
.docx文件转base64 再转回.docx文件 乱码问题 求帮助C# code://读取文件得到byte[]byte[] btFile FileTo

.docx文件转base64 再转回.docx文件 乱码问题 求帮助
C# code:
//读取文件 得到byte[]
byte[] btFile = FileToBinary(filePath + txtTrack.Text+".docx");
//byte 转 base64
String filedatas = System.Convert.ToBase64String(btFile);
//XLAjax 传filedatas到Java
  ...


Java code:
try{
//filedatas base64字符串 转byte[]
 byte[] buffer = new BASE64Decoder().decodeBuffer(filedatas);
 FileOutputStream out = new FileOutputStream(filePath);
 out.write(buffer);
 out.close();
}catch(Exception e){}


现在问题就是 生成的 .docx 乱码

[解决办法]
如果你验证过Java和C#的BASE64算法互通没有问题的话,无非就是传输的时候出问题了。
如果作为Get请求传,那么即便是Base64,在空格等特殊字符传输时应该有问题。

热点排行