1 / 5
文档名称:

javaio.doc

格式:doc   大小:47KB   页数:5页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

javaio.doc

上传人:文库旗舰店 2018/6/9 文件大小:47 KB

下载得到文件列表

javaio.doc

相关文档

文档介绍

文档介绍:12. 1. 文件输出流
import .*;
public class MainClass {
  public static void main(String[] args) {
    File originFile = new File("c:\\");
    File destinationFile = new File("c:\\");
    if (!() || ()) {
      return;
    }
    try {
      byte[] readData = new byte[1024];
      FileInputStream fis = new FileInputStream(originFile);
      FileOutputStream fos = new FileOutputStream(destinationFile);
      int i = (readData);
      while (i != -1) {
        (readData, 0, i);
        i = (readData);
      }
      ();
      ();
    } catch (IOException e) {
      (e);
    }
  }
}
12. 2. 从文件名创建一个文件输出流
import .*;
public class MainClass {
  public static void main(String[] a) {
    FileOutputStream outputFile = null; // Place to store the stream reference
    try {
      outputFile = new FileOutputStream("");
    } catch (FileNotFoundException e) {
      ();
    }
  }
}
12. 3. 从FileOutputStream创建DataOutputStream
import .*;
public class Main {
  public static void main(String[] args) throws Exception {
    FileOutputStream fos = new FileOutputStream("C:/");
    DataOutputStream dos = new DataOutputStream(fos);
  }
}
12. 4. 从File对象创建FileOutputStream对象
import