JAVA实例:java.io.File的写入写出

原创|其它|编辑:郝浩|2009-05-14 11:32:25.000|阅读 381 次

概述:本文是一篇关于java.io.File写入写出的一个简单的实例。

# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>

  import java.io.File;

  import java.io.FileInputStream;

  import java.io.FileNotFoundException;

  import java.io.FileOutputStream;

  import java.io.IOException;

  public class TestIO {

  /**

  * @param args

  */

  public static void main(String[] args)

  {

  // TODO Auto-generated method stub

  byte[] b = new byte[17*1024];

  // ** txt

  // File f = new File("d:\\test.txt");

  // File outF = new File("d:\\testOut.txt");

  // ** jpg

  File f = new File("d:\\毫无保留.jpg");

  File outF = new File("d:\\毫无保留Output.jpg");

  try

  {

  FileInputStream fis = new FileInputStream(f);

  FileOutputStream fops = new FileOutputStream(outF);

  fis.read(b);

  fops.write(b);

  // ** for see

  // String s = new String(b);

  // System.out.println(s);

  fis.close();

  fops.close();

  }

  catch(FileNotFoundException fnfe)

  {

  System.out.println("FileNotFoundException fnfe");

  fnfe.printStackTrace();

  }

  catch(IOException ie)

  {

  System.out.println("IOException ie");

  ie.printStackTrace();

  }

  }

  }


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com

文章转载自:IT专家网论坛

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP