文件下载

时间:2010-12-02 07:58:13

标签: java-me

如何连接服务器并检查是否有使用Java ME下载的文件?

我应该使用POST方法,将所有需要的数据发布到服务器并查看服务器响应的内容吗?还有什么标题我必须与我的数据一起发布?

或者我必须使用Get方法吗?

1 个答案:

答案 0 :(得分:0)

你手边不需要它。只需使用

HttpConnection connection = Connector.open(url);
DataInputStream stream = connection.openDataInputStream();
while(stream.read() != -1) {
    //your stuff if anything there
}