一个使用j2me和php的函数
/* *要更改此许可证标题,请在“项目属性”中选择“许可证标题”。 *要更改此模板文件,请选择工具|模板 *然后在编辑器中打开模板。 */ getsongs.php一个使用j2me和php的函数,php,java-me,Php,Java Me,/* *要更改此许可证标题,请在“项目属性”中选择“许可证标题”。 *要更改此模板文件,请选择工具|模板 *然后在编辑器中打开模板。 */ getsongs.php <?php echo "hi"; echo "jai"; ?> 有什么建议吗?首先,将httpconnection放在线程中是个好主意,当您打开InptStream时,必须将其放在线程中并尝试捕获 对我来说,这段代码一直都能完成任务 Thread connection = new Thread(new Runnab
<?php
echo "hi";
echo "jai";
?>
有什么建议吗?首先,将httpconnection放在线程中是个好主意,当您打开InptStream时,必须将其放在线程中并尝试捕获 对我来说,这段代码一直都能完成任务
Thread connection = new Thread(new Runnable(){
public void run(){
HttpConnection c;
InputStream is;
OutputStream out;
StringBuffer buff = new StringBuffer();
String err = null;
try{
//Connecting to server passing the data and setting the connection property
c = (HttpConnection)Connector.open(url);
c.setRequestMethod(HttpConnection.GET);
c.setRequestProperty("User-Agent","Profile/MIDP-2.1 Configuration/CLDC-1.1");
c.setRequestProperty("If-Modified-Since","9 Oct 2012 17:49:31 GMT");
c.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
c.setRequestProperty("Accept","text/html");
//Read From the File
try{
is = c.openInputStream();
//loop to read every character from file and append it to StringBuffer
int ch;
while((ch = is.read()) != -1){
buff.append((char) ch);
}
// now use the buffer will have al the data from php
}catch(Exception e){
}
}catch(Exception e){
display.setCurrent(text);
}
}
});
connection.start();
我希望这有帮助
javax.microedition.io.ConnectionNotFoundException: error 10061 in socket::open
at com.sun.midp.io.j2me.socket.Protocol.open0(), bci=0
at com.sun.midp.io.j2me.socket.Protocol.connect(), bci=209
at com.sun.midp.io.j2me.socket.Protocol.open(), bci=216
at com.sun.midp.io.j2me.socket.Protocol.openPrim(), bci=4
at com.sun.midp.io.j2me.http.Protocol.createConnection(), bci=41
Thread connection = new Thread(new Runnable(){
public void run(){
HttpConnection c;
InputStream is;
OutputStream out;
StringBuffer buff = new StringBuffer();
String err = null;
try{
//Connecting to server passing the data and setting the connection property
c = (HttpConnection)Connector.open(url);
c.setRequestMethod(HttpConnection.GET);
c.setRequestProperty("User-Agent","Profile/MIDP-2.1 Configuration/CLDC-1.1");
c.setRequestProperty("If-Modified-Since","9 Oct 2012 17:49:31 GMT");
c.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
c.setRequestProperty("Accept","text/html");
//Read From the File
try{
is = c.openInputStream();
//loop to read every character from file and append it to StringBuffer
int ch;
while((ch = is.read()) != -1){
buff.append((char) ch);
}
// now use the buffer will have al the data from php
}catch(Exception e){
}
}catch(Exception e){
display.setCurrent(text);
}
}
});
connection.start();