How can I download ony file from J2ME program?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Aitor_Zabaleta
Posted On:   Friday, November 29, 2002 02:29 AM

I wan´t to download files (*.txt *.jad *.prc ...) from my J2ME aplication, but:



Can J2ME do this? How?



Thank you very much.

Re: How can I download ony file from J2ME program?

Posted By:   Sailom_Nice  
Posted On:   Monday, December 16, 2002 02:44 AM

Sample Code


--------------------------------------------------------------

javax.microedition.io.HttpConnection h = null;

java.io.DataInputStream d = null;



try {

h = (HttpConnection)Connector. open("http://..../yourfile.here", Connecter.READ, false) ;

d = h.openDataInputStream();



byte[] data = new byte[h.getLength()]; //I couldn't not sure that method that get length is correct pls check from midp-doc

d.readFully(data);

}

catch (IOException ioe) { }


---------------------------------------------------------------------

now you get file content in variable "data" (I think :p)
Hope it's useful ...
About | Sitemap | Contact