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);
}
}
}path是文件名和路径,看看可以帮到不
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);
}
}
}path是文件名和路径,看看可以帮到不
我试了下是可以生产pdf,但是打不开,打开pdf就报错,说什么“adobe reader 无法打开PDF,说是不支持此文件类型或者文件已损坏xxxxx xxxx”
对,java 版叫 iText.