由于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){
}