J
JONESEY
Im trying to get a text file from a server and load it into a 2
dimensional array. So i came up with the follwoing method. The file is
a table using "|" to indicate the end of a cell and "¬" to indicate
the end of a row. I use if statements to find these but the if
statements done seem to to execute!! Any ideas?
J
void getFile(String url) throws IOException {
int x = 0;
int y = 0;
StreamConnection c = null;
InputStream s = null;
StringBuffer b = new StringBuffer();
TextBox t = null;
String temp;
try {
c = (StreamConnection)Connector.open(url);
s = c.openInputStream();
int ch;
while((ch = s.read()) != -1) {
temp = String.valueOf((char)ch);
if (temp == "|"){
fileArray[x][y] = b.toString();
x++;
b = null;
}
else if (temp == "¬"){
fileArray[x][y] = b.toString();
x = 0;
y++;
b = null;
}
else{
b.append((char) ch);
t = new TextBox("Fetch Page", b.toString(), 1024,
0);
}
}
dimensional array. So i came up with the follwoing method. The file is
a table using "|" to indicate the end of a cell and "¬" to indicate
the end of a row. I use if statements to find these but the if
statements done seem to to execute!! Any ideas?
J
void getFile(String url) throws IOException {
int x = 0;
int y = 0;
StreamConnection c = null;
InputStream s = null;
StringBuffer b = new StringBuffer();
TextBox t = null;
String temp;
try {
c = (StreamConnection)Connector.open(url);
s = c.openInputStream();
int ch;
while((ch = s.read()) != -1) {
temp = String.valueOf((char)ch);
if (temp == "|"){
fileArray[x][y] = b.toString();
x++;
b = null;
}
else if (temp == "¬"){
fileArray[x][y] = b.toString();
x = 0;
y++;
b = null;
}
else{
b.append((char) ch);
t = new TextBox("Fetch Page", b.toString(), 1024,
0);
}
}