cancel
Showing results for 
Search instead for 
Did you mean: 

Please help me, you all are my last change

Former Member
0 Kudos

Dear all,

I am new programmer of j2me.I have made a program which read data(text data) from a perticular webpage and after parsing it will show the data on a Form.When i run this program on PC using "J2ME Wireless Toolkit2.2" it works fine but when i run downloaded .jad/.jar file on a mobile it cannot read data from net shows "empty".All other part of the program run fine on mobile but cannot read data from a page.What should i do now.Please give me a solution,I am in deep trouble,please help me.My email address : sumon_192003@hotmail.com

Any help ,please send to this address.

Thank u all,

sumon.

Simple version of my program are as follows:

import java.io.*;

import javax.microedition.midlet.*;

import javax.microedition.io.*;

import javax.microedition.lcdui.*;

public class QuotesMIDlet extends MIDlet {

private Display display;

private String url = "http://www.yahoo.com";

public Form first_form;

public QuotesMIDlet() {

display = Display.getDisplay(this);

first_form = new Form("Updated list");

display.setCurrent(first_form);

}

public void startApp() {

try {

downloadPage(url);

} catch(IOException e)

{

first_form.append(new StringItem("","Error##"+e));

}

}

private void downloadPage(String url) throws IOException

{

StringBuffer b = new StringBuffer();

InputStream is = null;

HttpConnection c = null;

TextBox t = null;

try {

int ch;

c = (HttpConnection)Connector.open(url);

is = c.openInputStream();

//c.setRequestMethod(HttpConnection.GET);

while((ch=is.read())!=-1)

{

System.out.println("Charecter "(char)ch"Value of charecter "+ch);

first_form.append(new StringItem("# ",""+(char)ch));

}

//first_form.append(new StringItem("# ",""+is.read()));

}

catch(IOException e)

{

first_form.append(new StringItem("","Error##"+e));

}

finally {

is.close();

c.close();

}

}

public void pauseApp() {

}

public void destroyApp(boolean unconditional) {}

}

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hello sumon,

try the following code in your downloadPage method.

unfortunately i don't have any PDA to check this out.

hope that it will give you an idea...

URL url = new URL("http://www.yahoo.com");
HttpURLConnection c = (HttpURLConnection)url.openConnection();
DataInputStream dis = new DataInputStream(c.getInputStream());
byte[] data = new byte[c.getContentLength()];
dis.readFully(data);
String strData = new String(strData);
//display data to form... or parse it prior to display.

regards

jo

Former Member
0 Kudos

Hi Sumon,

This is not the right place for this question. The forum entertains all the questions related to SAP Mobile Business solutions and does not relate to standard j2me.

You can go to http://www.jguru.com for the support

Regards,

Ravi