Chinaunix首页 | 论坛 | 博客
  • 博客访问: 925377
  • 博文数量: 358
  • 博客积分: 8185
  • 博客等级: 中将
  • 技术积分: 3751
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 16:27
个人简介

The views and opinions expressed all for my own,only for study and test, not reflect the views of Any Company and its affiliates.

文章分类

全部博文(358)

文章存档

2012年(8)

2011年(18)

2010年(50)

2009年(218)

2008年(64)

我的朋友

分类: Java

2008-10-16 11:04:30

//用于文件输出 
 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 {
  }
阅读(615) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~