×

Discussion Board

Results 1 to 3 of 3

Hybrid View

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    9

    File reading issues in Nokia Asha 303

    Hi,

    I am reading a fixed number of characters from a file. The file contains both english and arabic text. I have two devices Nokia X3-02 and Nokia Asha 303 for testing. On Nokia X3-02, I am getting the correct string that I require from the file in every case. But on Asha 303, I do not get the complete string when the string contains some arabic character.

    I have also tested my code on the sun emulator and it is working fine on it too. The issue seams to be with Nokia Asha 303 device only.

    My code is a very simple one in which I read a file by specifying the reading position (Offset) and the length to be read. Please help me as I do not understand this problem.

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: File reading issues in Nokia Asha 303

    Hi abdul.wahab,

    This might be code related or software related. After some testing on Nokia 303 with software version 14.60, I was able to display on the screen a file that contained this String: "Some info يتس in Arabic" with this code:

    Code:
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import javax.microedition.io.Connector;
    import javax.microedition.io.file.FileConnection;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Form;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    
    public class FileReadTextMIDlet extends MIDlet {
    
    	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
    		// TODO Auto-generated method stub
    
    	}
    
    	protected void pauseApp() {
    		// TODO Auto-generated method stub
    
    	}
    
    	protected void startApp() throws MIDletStateChangeException {
    		Form mainForm = new Form("Arabic File Read");
    		Display.getDisplay(this).setCurrent(mainForm);
    		
    		 try {
    			 String filepath = System.getProperty("fileconn.dir.memorycard") + "testapp/test.txt";
    		     FileConnection fconn = (FileConnection)Connector.open(filepath);
    		     InputStream is = fconn.openInputStream();
    		     int size = is.available();
    		     InputStreamReader isr = new InputStreamReader(is, "UTF8");         
    		     char[] data = new char[size];
    		     isr.read(data);
    		     String output = new String(data);
    		     mainForm.append(output);
    		     is.close();
    		     fconn.close();
    		 }
    		 catch (IOException ioe) {
    			 System.out.println(ioe.getMessage());
    		 }
    	}
    }
    The text file should be placed in the memory card, under the path testapp/text.txt. Could you try again with this code? It might be that you need to update your device's software.

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    9

    Re: File reading issues in Nokia Asha 303

    Thanks skalogir

    I have managed to solve the issue. On Nokia x3-02 the app was reading the exact number of characters as specified in the read function of InputStreamReader but on Nokia Asha 303, the characters read were always less than the ones specified. So I had to loop the read function in order to read all characters. Now it is working on Nokia Asha 303.

Similar Threads

  1. Does On-Device Debugger also work with S40 1.1 Asha 303 SDK ?
    By jartl in forum Mobile Java Tools & SDKs
    Replies: 4
    Last Post: 2012-06-11, 18:32
  2. [moved] S40 application works on stimulator but falis on nokia 300 asha
    By PoojaKaregoudar in forum Nokia Asha Web Apps
    Replies: 9
    Last Post: 2012-03-30, 08:19
  3. nokia asha 302
    By Krishnarulezz in forum General Development Questions
    Replies: 2
    Last Post: 2012-03-05, 08:41
  4. Reading file takes more time on Nokia E61i while less time on Nokia 2626
    By arpit2agrawal in forum Mobile Java General
    Replies: 5
    Last Post: 2008-10-15, 14:57

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×