日期:2014-05-20 浏览次数:20758 次
byte[] buffer // 我得到的数据,这个数据成功转成pdf的话应该是运单label
String result = new String(buffer);
FileOutputStream fileOutputStream = new FileOutputStream(new File("C:templabelresult.pdf"));
fileOutputStream.write(Base64.decode(result.toCharArray()));
fileOutputStream.close();
public static void writeFile(String path,byte[] bytes){
int n = 1024;
FileOutputStream os = null;
try {
// 创建文件输出流对象
File file = new File(path);
os= new FileOutputStream(file);
// 写入输出流
int length = bytes.length;
int start = 0;
while(length>start+n){
os.write(bytes, start, n);
start= start+n;
}
if(length != start+n){
n = length-start;
os.write(bytes, start, n);
}
} catch (IOException e) {
LogUtils.logException(e);
}finally{
// 关闭输出流
try {
if(os !=null){
os.close();
}
} catch (IOException e) {
LogUtils.logException(e);
}
}
}