java实验报告8.1.docVIP

  • 14
  • 0
  • 约1.96千字
  • 约 5页
  • 2017-11-17 发布于河南
  • 举报
java实验报告8.1

JAVA第8.1次试验报告 实验8.1:文件流 姓名1、import java.io.*; public class FileStreamTest { public static void main(String[] args)throws IOException{ FileInputStream fis=null; FileOutputStream fos=null; try{ fis=new FileInputStream(source.jpg); fos=new FileOutputStream(dest.jpg); byte[]b=new byte[1024]; int count; while((count=fis.read(b))0) fos.write(b,0,count); } catch(IOException e){ e.printStackTrace(); } finally{ fis.close(); fos.close(); } } } 运行结果: 2、使用类FileReader/FileWriter读/写文件的示例。在系统当前目录下创建源文件source.txt,将源文件内容在控制台和目标文件dest.txt中输出,最后在控制台输出目标文件内容。 程序源代码: i

文档评论(0)

1亿VIP精品文档

相关文档