mam aplikację która łączy się z danym adresem url a konkretnie z plikiem php który tam jest. plik zwraca dane i tu wszystko fajnie działa.
problem z kodowaniem bo przy polskich znakach mam krzaki.
public void connect(String url) {
HttpConnection c = null;
InputStream is = null;
StringBuffer b = new StringBuffer();
StringTools st = new StringTools(";");
try {
c = (HttpConnection)Connector.open(url);
is = c.openDataInputStream();
int ch;
while((ch = is.read()) != -1) {
b.append((char) ch);
}
} catch(Exception ex) {}
int count = 0;
if(url.equals("http://jakasstrona.pl/index.php?id=mobilecontent&no_cache=1"))
count = st.split(b.toString()).length;
System.out.println(count);
if(count > 0) {
String[] test = new String[count];
test = st.split(b.toString());
list = new List("lista", List.IMPLICIT);
for(int i = 0; i < count; i++) {
list.append(test[i], null);
}
list.addCommand(CMD_OK);
list.addCommand(CMD_EXIT);
} else {
list = new List("lista", List.IMPLICIT);
String test = b.toString();
list.append(test, null);
list.addCommand(CMD_BACK);
// String test = b.toString();
// list.append(test, null);
}
list.setCommandListener(this);
mDisplay.setCurrent(list);
}
}
jak to przerobić ?
czytałem o readUTF obiektu DataInputStream, ale nic mi nie zwraca