码迷,mamicode.com
首页 > 编程语言 > 详细

Java基础知识强化之IO流笔记17:FileOutputStream构造方法使用

时间:2015-10-01 10:24:12      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!