Text 如何在j2me中解析文本数据并使用拆分将其存储在数组中?
如何在j2me中解析文本数据并使用拆分将其存储在数组中? 我继续执行下面的代码,我看到了所有的文本数据,但不能再进一步了。你能指引我吗Text 如何在j2me中解析文本数据并使用拆分将其存储在数组中?,text,split,java-me,Text,Split,Java Me,如何在j2me中解析文本数据并使用拆分将其存储在数组中? 我继续执行下面的代码,我看到了所有的文本数据,但不能再进一步了。你能指引我吗 /* * 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.
/*
* 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);
}
}
嗨,sagar,你到底想在这里做什么,你能用一个例子更具体一点吗?我想解析文本数据(&isrecent=1&r\u file\u 1=enau1605&r\u typ\u 1=ODI&r\u num\u 1=Final&r\u tma\u 1=England&r\u ven\u 1=Bridgetown&r\u tmb\u 1=AUS&r\u tmb\u 1=5月16日&r\u结果\u 1=England击败AUS 7 wickets&r\u ser\u 1=ICC World Twenty 20,2010&r\u TMU 1=1/TMU分数可显示格式为1/1476分)。