标签:
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
.
3. 代码示例:
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 }
Java基础知识强化之IO流笔记17:FileOutputStream构造方法使用
标签:
原文地址:http://www.cnblogs.com/hebao0514/p/4850675.html