简单的java版http代理(三)
[] buffer = new byte[bufferSize];
while((length = inputStream.read(buffer, 0, bufferSize)) > -1)
{
outputStream.write(buffer, 0, length);
}
outputStream.flush();
}
public static void copy(InputStream inputStream, OutputStream outputStream, int bufferSize, long size) throws IOException
{
if(size > 0)
{
int readBytes = 0;
long count = size;
int length = Math.min(bufferSize, (int)(size));
byte[] buffer = new byte[length];
while(count > 0)
{
if(count > length)
{
readBytes = inputStream.read(buffer, 0, length);
}
else
{
readBytes = inputStream.read(buffer, 0, (int)count);
}
if(readBytes > 0)
{
outputStream.write(buffer, 0, readBytes);
count -= readBytes;
}
else
{
break;
}
}
outputStream.flush();
}
}
}