How to Parse text data and store the same in array with splitting in j2me?
How to Parse text data and store the same in array with splitting in j2me? I have proceeded with the following code and I get to see all the text data but can't go any further. Can you guide me?
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
/**
* @author sagar
*/
public class Matches extends MIDlet {
String url = "***I cant show the link***";
private Display display;
public Matches() {
display = Display.getDisplay(this);
}
/**
* This will be invoked when we start the MIDlet
*/
public void startApp() {
try {
getViaHttpConnection(url);
} catch (IOException e) {
//Handle Exceptions any other way you like.
System.out.println("IOException " + e);
}
}
/**
* Pause, discontinue ....
*/
public void pauseApp() {}
/**
* Destroy must cleanup everything.
*/
public void destroyApp(boolean unconditional) {}
/**
* read url via Httpconnection
*/
public void getViaHttpConnection(String url) throws IOException {
HttpConnection con = null;
InputStream is = null;
StringBuffer buff = new StringBuffer();
String str = new String();
开发者_开发技巧 TextBox tb = null;
try {
con = (HttpConnection)Connector.open(url);
is = con.openInputStream();
int ch;
while((ch = is.read()) != -1) {
buff.append((char) ch);
str = buff.toString();
}
System.out.println(str);
tb = new TextBox("Matches", str, 1024, 0);
} finally {
if(is != null) {
is.close();
}
if(con != null) {
con.close();
}
}// display the contents of the file in a text box.
display.setCurrent(tb);
}
}
精彩评论