java认证:java.io.File写入写出的一个简单实例Java认证考试

文章作者 100test 发表时间 2009:05:16 21:01:27
来源 100Test.Com百考试题网


  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().
  }
  }
  }
  更多优质资料尽在百考试题论坛 百考试题在线题库 java认证更多详细资料

相关文章


java认证:常见的十四种Java开发工具的特点Java认证考试
java认证:java.io.File写入写出的一个简单实例Java认证考试
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛