8
Network
APIs
33
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);
= 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();
Содержание C381P J2ME
Страница 1: ...Technical Manual Version 01 00 Motorola C381p Handset J2ME Developer Guide ...
Страница 34: ...8 Network APIs 34 catch Exception ex hc i null Code Sample 3 HTTPS Connection ...
Страница 48: ...10 JSR 120 Wireless Messaging API 48 e toString Code Sample 5 JSR 120 Wireless Messaging API ...