?? newfile.txt
字號:
import java.io.*;
/**
* Description:
* <br/>Copyright (C), 2005-2008, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
public class FileOutputStreamTest
{
public static void main(String[] args) throws IOException
{
FileInputStream fis = null;
FileOutputStream fos = null;
try
{
//創(chuàng)建字節(jié)輸入流
fis = new FileInputStream("FileOutputStreamTest.java");
//創(chuàng)建字節(jié)輸入流
fos = new FileOutputStream("newFile.txt");
byte[] bbuf = new byte[32];
int hasRead = 0;
//循環(huán)從輸入流中取出數(shù)據(jù)
while ((hasRead = fis.read(bbuf)) > 0 )
{
//每讀取一次,即寫入文件輸出流,讀了多少,就寫多少。
fos.write(bbuf , 0 , hasRead);
}
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
finally
{
//使用finally塊來關(guān)閉文件輸入流
if (fis != null)
{
fis.close();
}
//使用finally塊來關(guān)閉文件輸出流
if (fos != null)
{
fos.close();
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -