[求助]小程序不太懂!
import java.io.*;public class FileIOTest1
{
public static void main(String[] args)
{
int count;
byte buf[]=new byte[2056]; //建立缓冲区
try
{
FileInputStream fileIn; //声明FileInputStream对象
FileOutputStream fileOut; //声明FileOutputStream对象
fileIn=new FileInputStream("c:\\qq\\Read.txt"); //创建输入流
(三)count=fileIn.read(buf); //从输入流fileIn读入数据到缓冲区
fileOut=new FileOutputStream("c:\\qq\\CopyMe.txt"); //创建输出流文件
(一)fileOut.write(buf,0,count); //从缓冲区把数据写入到输出流
//把文件FileIOTest1.txt中的内容显示出来
fileIn=new FileInputStream("c:\\qq\\CopyMe.txt");
count=fileIn.read(buf);
(二)String str=new String(buf,0,count);
System.out.println(str);
}
catch(IOException e)
{
System.out.println(e.toString());
}
}
}
(一)行,说是写到输出流,什么是输出流?不是写到buf数组吗?那那数组是做什么用的?
不太懂,请大家帮看看.
(二)行,String(buf,0,count)是NEW了一个构造方法吗?string有三个参数的吗?
(三)行,fileIn.read(buf)这里面的buf参数数组是什么意思?请解释下这行!
----------------解决方案--------------------------------------------------------
1,输出流就是把东西输出去的流,把数组里面的东西写到输出流里面去
2,是一个构造方法,String总共有13个构造方法,这只是其中的一个而已.哪13个?自己去看API
3,把输入流里面的东西读到缓冲数组里面来
----------------解决方案--------------------------------------------------------
所谓输入还是输出都是对内存来讲的
输入--就是往内存里输入 就是从外设读 相反 输出就是网外设里写啊
----------------解决方案--------------------------------------------------------