我正在从Java学习Java:完整参考。 我目前正在研究本章中的示例:输入/输出:浏览java.io 我完全理解下面示例中的几行代码。 任何人都可以帮助我用这个例子。请帮我理解下面的java代码
import java.io.*;
class FileInputStreamDemo
{
public static void main(String args[]) throws IOException
{
InputStream f = new FileInputStream("E://SomeRandomTextFile.txt");
System.out.println("Total available bytes : " + size = f.available());
int n = size/40;
System.out.println("First" + n + " bytes of file one read() at a time");
for(int i=0; i<n; i++)
{
System.out.println((char) f.read());
}
System.out.println("\n Still available: "+ f.available());
System.out.println("Reading the text " + n + " with one read(b[])");
byte b[] = new byte[n];
if(f.read(b) != n)
{
System.err.println("coudn't read" + n + "bytes.");
}
System.out.println(new String(b,0,n));
}
在上面的代码,我不力理解的代码的最后五行。
什么是
f.read(b)
结果是什么
System.err
和
什么是
new String(b,0,n);
雅编辑。谢谢你的回答。你的回答非常有帮助。 – user907629 2012-02-03 20:03:52