View Single Post
Old 11-24-2011, 08:33 PM   #10 (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
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)"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);

} catch (Throwable t) {

return fileContent;
Offline   Reply With Quote
The Following User Says Thank You to berryapp For This Useful Post:
bankkab (11-25-2011)