commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pablo Pinto <ppi...@cyc.cl>
Subject [net]
Date Wed, 06 Oct 2010 02:48:50 GMT
Hi Everybody:
Hi Everybody:

I'm using the FTP API and I need to use a limited bandwidth.

The following code works pretty good except for one problem. At
the beginning of the transference the program buffers 64KB of data using all
the available bandwidth. After that I can control the bandwidth.

OutputStream outputStream = new FileOutputStream(localFile);
InputStream inputStream = client.retrieveFileStream(remoteFile);

byte buf[] = new byte[bufferSize];
int bytesRead = inputStream.read(buf);
while (bytesRead != -1)
{
outputStream.write(buf, 0, bytesRead);
Thread.sleep(delay);
bytesRead = inputStream.read(buf);
}


Is it possible to decrease the amount of data that is buffered at the
begining?
Best Regards,

-- 
Pablo Pinto
Computación y Comunicaciones S.A.
Almirante Lorenzo Gotuzzo 124, Oficina 1500
Teléfonos : 9135704 - 9135700

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message