문제

i'm developing J2ME.
Could you mind helping me to find out whats wrong with this code:

HttpConnection c = null;

    try {
        c = (HttpConnection)Connector.open("http://www.mysite.com",Connector.READ_WRITE, true);
        c.setRequestMethod(HttpConnection.GET); //default
        is = c.openInputStream(); // transition to connected!
            int ch = 0;
        for(int ccnt=0; ccnt < 150; ccnt++) { // get the title.
            ch = is.read();
            if (ch == -1){
                break;
            }
                sb.append((char)ch);
        }
    }   
    catch (IOException x){
        x.printStackTrace();
    }
    finally{
        try     {
            is.close();
            c.close();
        } catch (IOException x){
            x.printStackTrace();
        }
    }
        System.out.println(sb.toString());


i'm trying open website through my app, thanks before :)

도움이 되었습니까?

해결책

J2ME에서 URL을 열려면 시스템이 아닌 스레드에서 다음을 수행합니다.

MIDlet.platformRequest("http://www.mysite.com/");

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top