HttpPost HttpPost   = new HttpPost();
     HttpPost.setPostUrl(Ptfsserver.PTFOPEN);
     InputStream indata  = HttpPost.Post(parameter);
//FS服务器是否操作成功!
byte[] flag        = new byte[1];
try
{
System.out.println(indata.available());
indata.read(flag); System.out.println(indata.available()+"+++");
if(!new String(flag).equals("1"))
{
return null;
}
}
catch (Exception e)
{
                return null;
}
上面的代码输出
266
0+++
为什么不是
265
0+++
呢?怎么read一次就不能在read了

解决方案 »

  1.   

    这个inputstream是HttpURLConnection 
    POST得到的
      

  2.   

    没太明白,是不是while(indata.read(flag)!=-1)  ?
      

  3.   

    这是从java doc里copy出来的available()
              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.你为什么期望他是265个字节呢?
      

  4.   

    available并不标示可读字符数...别理解错了
    唯一用来判断流读写的就是read方法
    while(indata.read(flag)!=-1){}if(indata.read(flag)!=-1){}