How can it be done? Whenever I do it, it downloads a file that is the right size, but seems to be corrupt (ie. can't open it).
Code:
HttpConnection conn = (HttpConnection)Connector.open(url);
InputStream fromServer = conn.openInputStream();
byte[] theBytes = new byte[(int)conn.getLength()];
int i;
while ((i = fromServer.read(theBytes)) != -1) {};
fromServer.close();
conn.close();
//create the file.
fc.create();
fc.setWritable(true);
DataOutputStream os = fc.openDataOutputStream();
os.write(theBytes);
os.flush();
os.close();
fc.close();
Comment