1. 可以參照之前寫的筆記: Android(java)學習筆記167:Java中操作檔案的類介紹(File + IO流)
2. FileOutputStream(常用的)構造方法:
FileOutputStream(File file)
Constructs a new FileOutputStream on the File file
. FileOutputStream(String filename)
Constructs a new FileOutputStream on the file named filename
1 package com.himi.fileoutputstream;
2
3 import java.io.File;
4 import java.io.FileNotFoundException;
5 import java.io.FileOutputStream;
6
7 /*
8 *
9 * 構造方法摘:
10 * FileOutputStream(String filename)
11 * Constructs a new FileOutputStream on the file named filename.
12 *
13 * FileOutputStream(File file)
14 * Constructs a new FileOutputStream on the File file.
15 *
16 */
17
18 public class FileOutputStreamDemo {
19
20 public static void main(String[] args) throws FileNotFoundException {
21 //FileOutputStream(File file)
22 File file = new File("fos.txt");
23 FileOutputStream fos = new FileOutputStream(file);
24
25 //FileOutputStream(String filename)
26 FileOutputStream fos1 = new FileOutputStream("fos.txt");
27
28 }
29
30 }