/*
* FileInputStream 用于读取诸如图像数据之类的原始字节流。要读取字符流,请考虑使用 FileReader
* FileInputStream 两种常用的构造法1.指定文件的路径名2指定文件 File
* 只有 read 一种读取方法
*
* 示例: 读取图片
*/
import java.io.* ;
public class FileStreamTest
{
public static void main(String[] args) throws Exception
{
//FileInputStream fin = new FileInputStream("C:\\Users\\jiaoda\\Desktop\\1.jpg");
// FileOutputStream fos =new FileOutputStream("D:\\copy_1.jpg");
FileInputStream fin = new FileInputStream("C:\\Users\\jiaoda\\Desktop\\1.txt");
FileOutputStream fos =new FileOutputStream("D:\\copy_1.txt");
byte [] buf = new byte[fin.available()];
fin.read(buf);
fos.write(buf);
/*
byte [] buf = new byte[1024];
while(fin.read(buf)!=-1)
{
System.out.println(new String(buf, 0,buf.length));
}
*/
fin.close();
fos.close();
}
}