View Single Post
Old 11-25-2011, 10:28 AM   #12 (permalink)
Knows Where the Search Button Is
Join Date: Nov 2011
Model: 9800T
Carrier: Rogers Canada
Posts: 34
Post Thanks: 3
Thanked 5 Times in 5 Posts
Default Re: Read String in File text.

Originally Posted by bankkab View Post
here this code

class Connect extends MainScreen {

Connect() {

FileConnection fc = null;
String fileContent = "";
try {
fc = (FileConnection)"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);

} 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