我有一个 BufferedInputStream 和一个 BufferedOutputStream 的上传,现在我想获得这个上传百分比的进度。
这个怎么弄??
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try
{
URL url = new URL( sb.toString() );
URLConnection urlc = url.openConnection();
bos = new BufferedOutputStream( urlc.getOutputStream() );
bis = new BufferedInputStream( new FileInputStream( source ) );
int i;
int progress = 0;
while ((i = bis.read()) != -1)
{
bos.write( i );
//how to get the progress here?!
}
}
finally
{
if (bis != null)
try
{
bis.close();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
if (bos != null)
try
{
bos.close();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
}