Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User gracy's Avatar
    Join Date
    Nov 2010
    Posts
    43
    I wrote a MIDlet that shows the subfolder and file of the folder you choose. It is an assignment.
    and the folder and files can be opened.
    But I can open and read only .txt files and for pictures, I can read only .png file.
    if the MIDlet can not open .doc file and other pictures, what is the use of such kind of program?

  2. #2
    Nokia Developer Champion raj_J2ME's Avatar
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,314
    Quote Originally Posted by gracy View Post
    if the MIDlet can not open .doc file and other pictures, what is the use of such kind of program?
    How are you reading the files like png, and txt etc?

    Can you share the code for reading?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Registered User gracy's Avatar
    Join Date
    Nov 2010
    Posts
    43
    Why?
    It may be just a piece of cake for you and it may have many flaws. Anyway, here is my coding.
    Code:
    try {
    			fileconnection=(FileConnection)Connector.open("file:///root1");  //place the file you want to read here
    			InputStream is = fileconnection.openInputStream();
    			StringBuffer sb = new StringBuffer();
    			int chr, i = 0;
    			// Read until the end of the stream 
    			while ((chr = is.read()) != -1)
    			sb.append((char) chr);
    			//System.out.println(sb.toString());
    			Alert alert=new Alert("",sb.toString(),null,AlertType.INFO);
    			SecondTestFileMIDlet.secondtestfilemidlet.display.setCurrent(alert);
    			
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    Code:
    FileConnection connection = (FileConnection) Connector.open(
    			"file:///root1/read/tree.png");
    			
    					InputStream iStrm = connection.openInputStream();
    					Image im = null;
    					ImageItem imageitem;
    					
    					byte imageData[]=new byte[2500];					
    					ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
    					int ch;
    					while ((ch = iStrm.read()) != -1)
    					bStrm.write(ch);
    					imageData = bStrm.toByteArray();
    					bStrm.close();					
    					im = Image.createImage(imageData, 0, imageData.length);
    					imageitem=new ImageItem("",im,1,"");
    					append(imageitem);

Similar Threads

  1. Signing MIDlet using system.getproperty()
    By ankurb43 in forum General Development Questions
    Replies: 4
    Last Post: 2010-06-01, 16:23
  2. MIDlet access System SIP Profile
    By thesti in forum Mobile Java General
    Replies: 0
    Last Post: 2009-10-19, 14:51
  3. avoiding signing, having multiple files into one file (private file system)
    By karstenSpr in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2008-08-12, 08:48
  4. System.out redirector midlet installation problem
    By d_sanjay in forum Mobile Java General
    Replies: 0
    Last Post: 2005-10-12, 01:53
  5. Running System.gc() in a midlet
    By gilad_l100 in forum Mobile Java General
    Replies: 1
    Last Post: 2003-08-28, 10:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved