关于获取 InputStream 输入流的 字节数

现在要获取 InputStream 流的字节数,
所以用 available()获取字节长度 ,结果出错 报IO异常

下面为代码部分:
调用下面方法时,会传入一个有内容的 输入流

[code="java"]
public final void writeInputStream(InputStream in,OutputStream out){
try
{

int len = in.available(); //这一行报错!!!

       byte[] data=new byte[1024*1024*10];
       int bytesRead=0;
       while((bytesRead=in.read(data,0,1024*1024*10))!=-1)
       {
         out.write(data, 0, bytesRead);
       }
       in.close();
       out.close();           

    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
   }

[/code]
[b]问题补充:[/b]
为什么
[code="java"]
while((bytesRead=in.read(data,0,1024*1024*10))!=-1)

[/code]
这个方法可以获取流的字节数,
而我直接用 in.available(); 获取字节数却出错,并且有 IOException?

[quote]available
public int available()
throws IOException
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or or another thread. [/quote]

请参照JavaAPI;

具体异常是什么呢?

while((bytesRead=in.read(data,0,1024*1024*10))>-1)