- 113 名前:デフォルトの名無しさん [04/08/24 18:58]
- MIDPのhttp接続について質問させてください。最初にソースです。finallの処理は省略してますy
public String setHTTPConnection( String service, String dat, int len ) { String url = "localhost/test/test.php&dat="; HttpConnection con = null; InputStream in = null; try{ con = (HttpConnection)Connector.open(url,Connector.READ,true); con.setRequestMethod(HttpConnection.GET); in = con.openInputStream(); int length = (int)con.getLength(); if(length<0) { ByteArrayOutputStream _o = new ByteArrayOutputStream(); byte[] buf = new byte[len]; int t = 0; while((t=in.read(buf))!=-1){ _o.write(buf,0,t); } _o.close(); str = new String(_o.toByteArray()); }else{ byte[] buf = new byte[length]; in.read(buf); str = new String(buf); } } catch(Exception e){} return str; }
|

|