Java初心者、IOの使用FileOutputStreamとFileWriter書き込みファイル(42)


import java.io.*;
public class FileOutputStreamTest 
{
	public static void main(String[] args) throws IOException
	{
		FileInputStream fis = null;
		FileOutputStream fos = null;
		try
		{
			//       
			fis = new FileInputStream("FileOutputStreamTest.java");
			//       
			fos = new FileOutputStream("newFile.txt");
			byte[] bbuf = new byte[32];
			int hasRead = 0;
			//           
			while((hasRead = fis.read(bbuf)) > 0)
			{
				//     ,        ,    ,    
				fos.write(bbuf,0,hasRead);
			}
		}
		catch (IOException ioe)
		{
			ioe.printStackTrace();
		}
		finally
		{
			if(fis != null)
			{
				fis.close();
			}
			if(fos != null)
			{
				fos.close();
			}
		}
	}
}