//用于文件输出
FileOutputStream fos = new FileOutputStream(outputFile);
// 第一中方法
//从一个文件中读取内容
File f = new File(headerName);
FileInputStream fis = new FileInputStream(f);
try {
byte[] b = new byte[(int)f.length()];
int icount = 0;
while ((icount = fis.read(b)) > 0) {
//向输出文件中写入读入的内容
fos.write(b, 0, icount);
}
fos.flush();
} catch (Exception ex) {
throw new Exception(ex);
} finally {
fis.close();
}
// 第二中方法,随机读写,
try {
RandomAccessFile rf = new RandomAccessFile(filname, "rw");
rf.seek(rf.length());// to the file tail
rf.writeBytes(flow);
rf.close();
} catch (IOException e) {
} finally {
}
阅读(662) | 评论(0) | 转发(0) |