Motorola C381P technical manual Network APIs

Models: C381P

1 130
Download 130 pages 15.6 Kb
Page 33
Image 33

8

Network APIs

try {

is[i] = hc[i].openInputStream();

byteCounts[i] = 0;

readLengths[i] = hc[i].getLength();

System.out.println("readLengths = " +

readLengths[i]);

if (readLengths[i] == -1)

{

readLengths[i] = BUFFER_SIZE;

}

int bytes_read = 0; int offset = 0;

int bytes_left = (int)readLengths[i];

do

{

bytes_read = is[i].read(buffer, offset,

bytes_left);

offset += bytes_read; bytes_left -= bytes_read; byteCounts[i] += bytes_read;

}

while (bytes_read > 0);

System.out.println("byte read = " +

byteCounts[i]);

} catch (Exception ex) {

System.out.println("Downloading Failed: "+

ex.getMessage());

numPassed = 0;

}

finally { try {

is[i].close(); is[i] = null; } catch (Exception ex) {}

}

}

/**

*close http connection

*/

if (hc[i] != null)

{

try { hc[i].close();

33

Page 33
Image 33
Motorola C381P technical manual Network APIs