View Single Post
Old 11-25-2011, 10:28 AM   #12
berryapp
Knows Where the Search Button Is
 
Join Date: Nov 2011
Model: 9800T
PIN: N/A
Carrier: Rogers Canada
Posts: 34
Default Re: Read String in File text.

Quote:
Originally Posted by bankkab View Post
here this code

class Connect extends MainScreen {



Connect() {


FileConnection fc = null;
String fileContent = "";
try {
fc = (FileConnection)Connector.open("file:///D:/IP.txt");
if ( (fc==null) || !fc.exists()){
return "File does not exist";
}

InputStream in = fc.openInputStream();
byte[] data = IOUtilities.streamToBytes(in);
fileContent = new String(data);

in.close();
fc.close();
} catch (Throwable t) {

}
return fileContent;
}

}

it error " cannot return a value from method whose result type is void "

where is a void i don't declare a void function
Since your method returns String, so you need to have the method declaration accordingly, i.e.,
String Connect() { //instead of Connect() {
Offline   Reply With Quote