package deme2;
public class IODemo09
{
public static void main(String args[]) throws IOException
{
byte[] b=new byte[10];
File f = new File("f:\\ff.txt") ;
InputStream in = null;
OutputStream out=null;
in=new FileInputStream(f);//对抽象类对象in实例化
int len=in.read(b);//len为字符的长度
//String str=new String(b)//会把后面的空格转换成字符串
//而下面的构造函数则去除了空格
String str=new String(b,0,len);
System.out.print(str);
//从键盘输入字符,若字符长度小于9,则为长度+2,若大于等于9,则都为10
//因为按下回车键产生"\r","\n"两个字符,而b允许的最大长度为10
System.out.println("received number="+System.in.read(b));
System.out.println("----------------");
}
}