Motorola maxx V6 manual Draft Subject to Change 155/201

Models: maxx V6

1 201
Download 201 pages 31.32 Kb
Page 155
Image 155

Java ME Developer Guide

Chapter 22 - Network APIs

hc[i] = null;

System.out.println("Open Failed: " + ex.getMessage());

}

if (hc[i] != null)

{

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) {}

}

}

DRAFT - Subject to Change [155/201]

Page 155
Image 155
Motorola maxx V6 manual Draft Subject to Change 155/201