0
BufferedInputStream 및 BufferedOutputStream을 사용하여 업로드 한 결과를 얻었으며 이제이 업로드의 진행률을 확인하고 싶습니다.BOS/BIS가 진행 중임
이걸 얻는 방법 ??
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();
}
}
java에 포함 된 공용 라이브러리에서이 작업을 수행 할 수있는 방법이 있습니까? – bbholzbb
글쎄, 실제로 당신은 당신 자신에 의해 이러한 단순한 래퍼를 구현할 수 있습니다. 단지 그들이 어떻게 생성되는지보십시오 (Commons 라이브러리는 오픈 소스 임). 그러나 표준 Java 클래스에서'Counint * Stream'과 같은 준비된 클래스는 없습니다. – Andremoniy