I tried to read Data from an HTTP Connection as a first time.
But it does not work.
The message is
javax.microedition.io.ConnectionNotFoundException: Could not resolve hostname
I tried to open http://www.jimkeogh.com/index.htm. that is the web site really exist.
What steps I have to do?
Code:StreamConnection connection; try { connection = (StreamConnection)Connector.open("http://www.jimkeogh.com/index.htm"); InputStream in = connection.openInputStream(); StringBuffer buffer = new StringBuffer(); int ch; while (( ch = in.read()) != -1) { if (ch != '\n') { buffer.append((char) ch); } else { System.out.println(buffer.toString()); buffer.delete(0, buffer.length()); } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }

Reply With Quote




