Regarding reading from a file in mobile memory card.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Karan_Rawat
Posted On:   Saturday, October 2, 2010 01:02 PM

I am using Netbeans 6.9 to make a midp application(midp 2.1 cldc 1.1). I am using FileConnection class to create a connection then using a InputStream to read it. Then to know the read content from the file present in the same directory as is the application, I am setting Label of a TextField object as the data read from the file. But this does not work. Where is the problem with my code? Note :- The name of my storage card is "Memory card". public void readfile() { FileConnection conn = (FileConnection)Connector.open("file:///Memory card/text.txt",Connector.READ); InputStream is = conn.openInputStream(); byte[] b = new byte[100]; try   More>>


I am using Netbeans 6.9 to make a midp application(midp 2.1 cldc 1.1). I am using FileConnection class to create a connection then using a InputStream to read it. Then to know the read content from the file present in the same directory as is the application, I am setting Label of a TextField object as the data read from the file. But this does not work. Where is the problem with my code?



Note :- The name of my storage card is "Memory card".




public void readfile()

			{
			
FileConnection conn = (FileConnection)Connector.open("file:///Memory card/text.txt",Connector.READ);
InputStream is = conn.openInputStream();
byte[] b = new byte[100];
try{
is.read(b);
}catch(Exception e){}
String txt = b.toString();
textField.setLabel(txt);
try{
is.close();
}catch(Exception e){}
}

   <<Less
About | Sitemap | Contact