import java.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class Test extends MIDlet {
public void startApp() {
String str = "null";
try {
Class c = this.getClass();
InputStream is = c.getResourceAsStream("/geo_kurz.dat");
InputStreamReader isr = new InputStreamReader(is);
str = readLine(isr);
System.out.println(str);
} catch (IOException e) {
e.printStackTrace();
}
Display display = Display.getDisplay(this);
TextBox tb = new TextBox("test", str, str.length(), 0);
display.setCurrent(tb);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
/**
* Read one line from the Reader. A line may be terminated
* by a single CR or LF, or the pair CR LF.
* @param aReader The Reader to read characters from.
* @return Next physical line.
* @throws IOException if anything goes wrong.
*/
boolean CRState = false;
protected String readLine(Reader aReader) throws IOException {
StringBuffer sb = new StringBuffer();
boolean done = false;
while (!done) {
int result = aReader.read();
if (result == -1) {
if (sb.length() > 0) {
break;
}
return null; // also possible is: throw new EOFException();
}
else {
char ch = (char) result;
if (ch == '\n') { // LF
if (CRState) {
CRState = false;
continue;
}
break;
}
else {
if (ch == '\r') {
CRState = true;
break;
}
else {
sb.append(ch);
CRState = false;
}
}
}
}
return sb.toString();
}
}