Quote:
Originally Posted by bankkab
Can you Give me a sample code for
read string in my Text file please
|
Here is a method. After you start the simulator, first save a file temp.txt making sure that there is a file by that name and appropriate location.
---------------------------------------------------------
public String readFile() {
FileConnection fc = null;
String fileContent = "";
try {
fc = (FileConnection)Connector.open("file:///store/home/user/temp.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;
}