tags:

views:

139

answers:

0

I have code that successfully displays html

import java.io.DataInputStream;
import java.io.IOException;

import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;


public class Example extends MIDlet implements CommandListener {
.
.
.
.
.

private String requestUsingGET(String URLString) throws IOException {
    HttpConnection hpc = null;
    DataInputStream dis = null;
    boolean newline = false;
    String content = "";
    try {
      hpc = (HttpConnection) Connector.open(URLString);
      dis = new DataInputStream(hpc.openInputStream());
      int character;

      while ((character = dis.read()) != -1) {
        if ((char) character == '\\') {
          newline = true;
          continue;
        } else {
          if ((char) character == 'n' && newline) {
            content += "\n";
            newline = false;
          } else if (newline) {
            content += "\\" + (char) character;
            newline = false;
          } else {
            content += (char) character;
            newline = false;
          }
        }

      }
      if (hpc != null)
        hpc.close();
      if (dis != null)
        dis.close();
    } catch (IOException e2) {
    }

    return content;
  }
}

. but other than I want to display WAP.what to add on this in my code? to display the WAP browser. because when I tried to address wap.yahoo.com is not in response by the system