| Reply | « Previous Thread | Next Thread » |
|
Hi!
I have written an application that reads a txt-file from the internet and parses it for newline("\n"). If a new line begins, the Stringbuffer is added to a vector. The result is a vector, containing the lines from the txt-file as elements. So far so good, it works phantastic with the S60-Concept emulator or the default Colour-phone emulator, but NOT on a _real_ Nokia 3650/7650. Seems that the vector is empty, cause ive written an alert that occours on the phone, if the vector is empty. This alert occours every time after making the connection. So i think the problem must be near the line where parsing the '\n'. If i look into the connection-log in the Nokia 3650, there is traffic (exactly the size of my txt-file). I really don´t know, where the failure is, thanks for any help!! Here comes the code: Code:
private void readQuestions() {
StreamConnection conn=null;
InputStream in = null;
StringBuffer data = new StringBuffer();
try {
// Open the HTTP connection
conn = (StreamConnection)Connector.open("http://www.my-server.de/Fragen.txt",Connector.READ);
// Obtain an input stream for the connection
in = conn.openInputStream();
// Read a line at a time from the input stream
int ch;
while ((ch=in.read()) != -1) {
if ((char)ch != '\n') {
// Read the line one character at a time
data.append((char)ch);
}
else {
// Add the question to the fragen vector
fragen.addElement(data.toString());
// Clear the string for the next line
data = new StringBuffer();
}
}
}
catch (IOException e) {
System.err.println("The connection could not be established.");
}
try{
conn.close();
}
catch (IOException e) {
System.err.println("Failure while closing the connection");
}
}
|
|
Now i have tried the application with another net-access-protocol, (D2-Vodafone Wap via GPRS), and i had no problems!! I have noticed that the difference is in the gateway-adress (with 0.0.0.0, Adress was web.vodafone.de nothing happens, with gateway 139.7.29.1 and adress live.vodafone.com it works fine). Seems to be a provider-problem.
|
|
Hi,
Im a final year compsci student, and I am using very similar code to read a file from a tomcat server. I've run into a problem, please let me know if you've run into a similar problem, or have a solution. For sum reason when I extract a string from the file, containing say "2" or "3", and pass the string as a parameter to Integer.parseInt(), a NumberFormatException is generated, even though I KNOW the string only contains a single numerical digit.. Any ideas? |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|