Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified
Accepted Solution

IOException : File system not ready

Hello guys'

I have some problem. It is reading files with extension *.txt. 

In that time :  net.rim.device.api.io.file.FileIOException: File system not ready

What is wrong in here ? 

 

long skipByteNumber = 800; FileConnection fconn = null; InputStream inputStream = null; try { fconn = (FileConnection)Connector.open(filePath); inputStream = fconn.openInputStream(); InputStreamReader isr = new InputStreamReader(inputStream); long skipNum = isr.skip(skipByteNumber); System.out.println("Skip : " + skipNum); if(fconn.fileSize() > skipNum) { int readlen = (int)(fconn.fileSize() - skipNum); char[] readData = new char[readlen]; isr.read(readData, 0, readlen - 1); StringBuffer sb = new StringBuffer(); sb.append(readData); StringBuffer tmp = new StringBuffer(); int **bleep**num = 0; ...... } } catch(IOException ioe) { /*final String str = filePath; UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Dialog.alert("File is missing : " + str); } });*/ System.out.println("Ex1 : " + ioe.toString()); System.out.println("Ex1 : " + ioe.getMessage()); } finally { if(fconn != null) { try { fconn.close(); } catch(IOException ioe) { System.out.println("Close : " + ioe.toString()); } } }

 

 

 

Please use plain text.
New Developer
petritis
Posts: 14
Registered: ‎07-16-2008
My Device: Not Specified

Re: IOException : File system not ready

I don't know if it is your problem or not, but when I tried working with files I had the wrong path.

Once I found the right path things started working fine.

I am working with an SD Card and this is the path to the 'root' directory of it:

 

"file:///SDCard/BlackBerry/"

 

Hopefully that helps.

 

Please use plain text.
Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: IOException : File system not ready

I've found coding mistake. If ur code is using object of InputStream, u must close that object'

 

Code : 

 

InputStream ins = .....

 

....

 

ins.clode();

 

 

 

Please use plain text.