Base64转换 2019-05-31

由于Base64能保持对象消息的完整性,生产环境中使用它保存交易中心下发的交易文件。在后续的测试中,需要还原文件为交易的对象,这样便于操作。

File file = new File("Base64文件");

byte[] b= new byte[1024];

String data="";

String line="";

SrcData msg=null;

try{

    FileInputStream fis = new FileInputStream(file);

    InputStreamReader isr = new InputStreamReader(fix);

    BufferedReader br = new BufferedReader(isr);

    while((line = br.readLine()) != null){

        data += line;

    }

    b = Base64Coder.base64ToByteArray(data);

    ByteArrayInputStream bais = new ByteArrayInputStream(b);

    ObjectInputStream ois = new ObjectInputStream(bais);

    ExceutionReport report = (ExceutionReport)ois.readObject();

}catch(IOException e){

}catch(ClassNotFoundException ce){

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容