FileConnection problems

Hi,
I have an xml file which I would like to parse, for some reason I can not read the file. It would be great if I could get any help. I am using the Sony Ericsson wtk. I am using the SonyEricsson K750i emulator. I have stored the file (called map.xml) is stored in its root1 and c:/ and e:/ directory (I have tried accessing all of them). My code to access is as follows:
FileConnection conn;
          InputStream in = null;
          try {
               System.out.println("Does it get here?");
               conn = (FileConnection)Connector.open(xmlUri);
               if(!conn.exists()){
                    conn.create();
               in = conn.openInputStream();
               Reader reader = new InputStreamReader(in);this continues on to parse the file(which havent tested out yet)
this gives a null pointer exception
before I call this code I call the following methods
private void walkEntireDirectoryStructure(){
          System.out.println("Starting to walk Directory Structure");
          Enumeration e = FileSystemRegistry.listRoots();
          while (e.hasMoreElements()){
               String root = (String)e.nextElement();
            System.out.println("Root found: " + root);
            try {
                    FileConnection fc = (FileConnection)Connector.open(root);
                    if(fc.isDirectory()){
                         System.out.println("Is a directory");
                         walkDirectoryTree(fc);
                    }else{
                         System.out.println("NOT a directory");
               } catch (IOException e1) {
                    System.out.println("Failed to open fileConnection! " + e.toString());
               } catch(Throwable e1){
                    System.out.println("Yep, it's crap");
                    e1.printStackTrace();
          System.out.println("Finished Walking Directory Structure");
     private void walkDirectoryTree(FileConnection fc){
          try {
               Enumeration files = fc.list();
               while(files.hasMoreElements()){
                    String file = (String)files.nextElement();
                    System.out.println("Found: " + file);
                    FileConnection fileConn = (FileConnection)Connector.open(file);
                    if(fileConn.isDirectory()){
                         System.out.println("Found Directory: " + file + " |Starting to walk!");
                         walkDirectoryTree(fileConn);
                    }else{
                         System.out.println("Found File: " + file);
                    System.out.println("Found fil");
          } catch (IOException e) {
               System.out.println("Failed to get Enumeration of files: " + e.toString());
     }This should show all the files in the directories root1, c:/ and e:/
sample error code is:
*Running with storage root root1
Starting to walk Directory Structure
Root found: c:/
java.lang.ClassNotFoundException: com/sun/midp/io/j2me/c/Protocol
     at javax.microedition.io.Connector.openPrim(+255)
     at javax.microedition.io.Connector.open(+15)
     at javax.microedition.io.Connector.open(+6)
     at javax.microedition.io.Connector.open(+5)
     at valerie.xml.UnMarshal.walkEntireDirectoryStructure(+51)
     at valerie.xml.UnMarshal.parse(+4)
     at valerie.ui.screens.TestXmlScreen$ParseXML.run(+14)
java.lang.ClassNotFoundException: com/sun/midp/io/j2me/c/Protocol
     at javax.microedition.io.Connector.openPrim(+255)
     at javax.microedition.io.Connector.open(+40)
     at javax.microedition.io.Connector.open(+6)
     at javax.microedition.io.Connector.open(+5)
     at valerie.xml.UnMarshal.walkEntireDirectoryStructure(+51)
     at valerie.xml.UnMarshal.parse(+4)
     at valerie.ui.screens.TestXmlScreen$ParseXML.run(+14)
Failed to open fileConnection! javax.microedition.io.file.FileSystemRegistry$1@1a4cfaaa
Root found: e:/
java.lang.ClassNotFoundException: com/sun/midp/io/j2me/e/Protocol
     at javax.microedition.io.Connector.openPrim(+255)
     at javax.microedition.io.Connector.open(+15)
     at javax.microedition.io.Connector.open(+6)
     at javax.microedition.io.Connector.open(+5)
     at valerie.xml.UnMarshal.walkEntireDirectoryStructure(+51)
     at valerie.xml.UnMarshal.parse(+4)
     at valerie.ui.screens.TestXmlScreen$ParseXML.run(+14)
java.lang.ClassNotFoundException: com/sun/midp/io/j2me/e/Protocol
     at javax.microedition.io.Connector.openPrim(+255)
     at javax.microedition.io.Connector.open(+40)
     at javax.microedition.io.Connector.open(+6)
     at javax.microedition.io.Connector.open(+5)
     at valerie.xml.UnMarshal.walkEntireDirectoryStructure(+51)
     at valerie.xml.UnMarshal.parse(+4)
     at valerie.ui.screens.TestXmlScreen$ParseXML.run(+14)
Failed to open fileConnection! javax.microedition.io.file.FileSystemRegistry$1@1a4cfaaa
Root found: root1/
Yep, it's crap
java.lang.IllegalArgumentException: no ':' in URL
     at javax.microedition.io.Connector.openPrim(+37)
     at javax.microedition.io.Connector.open(+15)
     at javax.microedition.io.Connector.open(+6)
     at javax.microedition.io.Connector.open(+5)
     at valerie.xml.UnMarshal.walkEntireDirectoryStructure(+51)
     at valerie.xml.UnMarshal.parse(+4)
     at valerie.ui.screens.TestXmlScreen$ParseXML.run(+14)
Finished Walking Directory Structure
Uncaught exception java/lang/IllegalArgumentException: no ':' in URL.
Does it get here?
Execution completed.
0 bytecodes executed*

Well, just a quick try to answer your question:
1. You got ClassNotFoundException...
Are you sure you have included:
import javax.microedition.io.file.*;
import java.util.Enumeration; ? Maybe you have as you got no compilation error...
2. All file browsing should be performed in a separate thread. - inside run()
3. I've managed to develop a system traversing file system up and down the tree. 2 short code snippets:
        //browsing root list
        try
            Enumeration enumRoots = FileSystemRegistry.listRoots();
            String currentRoot = null;
            while (enumRoots.hasMoreElements())
               currentRoot = (String) enumRoots.nextElement();
               //do sth. with currentRoot
      catch(IllegalArgumentException e)
       catch (SecurityException e)
      catch(Exception e)
      //browsing folder list  (try + catch omitted).  m_fileConn is a member variable and was opened with:
       m_fileConn = (FileConnection) Connector.open("file:///"+m_sNewSubpath, Connector.READ); 
       m_fileConn.setFileConnection(m_sNewSubpath);  //usage of a subtath. Initially a root. then a folder inside the root.  (could be ".." when going up)
       if(m_fileConn.isDirectory())
          String element;
          Enumeration dirElements = m_fileConn.list();
          while (dirElements.hasMoreElements())
              element = (String)dirElements.nextElement();
              //use element           
       else
            //...

Similar Messages

  • FileConnection problem

    I am using wireless tollkit for accessing the files in memory card. It is working perfect in system. when I installed the application in mobile the fileconnection was not working..
    In nokia 3230 its giving java.lang.error.
    In motorola L6 it didnt display anything.
    please anyone help me.
    Thanks in advance

    It's exactly what I'm saying about: you are limited to the 'roots' which implementation provides to you. In your case they are CFcard,SDcare,root1. (and actually any other folder, which you create under D:\WTK25\appdb\DefaultColorPhone\filesystem)
    There is no possibilty with any J2ME API directly access the Local disks.
    You need to provide some sort of brigde like servlet on application server to be able to transfer the files from you phone (or emulator) to the local discs of computer.
    regarding the transfer of files to servlets see other threads in this forum, like:
    http://forum.java.sun.com/thread.jspa?threadID=5152559

  • FileConnection API problem ......

    I tried this example on emulator and it gives the expected output.
    But when i tried this on N70 and 6230i ...it shows only the root directories . And it does not show the file's contents. Can u pls tell me what the problem might be ?
    (when i ran this on emulator i changed the : "c:/" to "foldername")
    package test_file;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.file.*;
    import javax.microedition.io.*;
    import java.io.*;
    import java.util.*;
    public class Displayable2
    extends Form
    implements CommandListener {
    StringItem stringItem1;
    String root = "";
    StringBuffer sb = new StringBuffer();
    StringItem stringItem2;
    byte by[] = null;
    /** Constructor */
    public Displayable2() {
    super("Displayable Title");
    try {
    jbInit();
    catch (Exception e) {
    e.printStackTrace();
    /**Component initialization*/
    private void jbInit() throws Exception {
    // Set up this Displayable to listen to command events
    stringItem1 = new StringItem("", "");
    stringItem2 = new StringItem("", "");
    stringItem1.setText("");
    setCommandListener(this);
    // add the Exit command
    addCommand(new Command("Exit", Command.EXIT, 1));
    this.append(stringItem1);
    this.append(stringItem2);
    getRoots();
    createFile();
    showFile("mynewfile.txt");
    private void getRoots() {
    try {
    Enumeration drives = FileSystemRegistry.listRoots();
    System.out.println("The valid roots found are: ");
    while (drives.hasMoreElements()) {
    root = (String) drives.nextElement();
    sb.append(root + "\n");
    stringItem1.setText(sb.toString());
    System.out.println("\t" + root);
    catch (Exception ex) {
    System.out.println(ex);
    public void createFile() {
    try {
    FileConnection filecon = (FileConnection)
    Connector.open("file:///C:/mynewfile.txt");
    // Always check whether the file or directory exists.
    // Create the file if it doesn't exist.
    if (!filecon.exists()) {
    filecon.create();
    OutputStream is = filecon.openOutputStream();
    String s = new String("we are the best kept secret of the universe,our mission is to monitor extra terrestrial activities onearth");
    byte b[] = s.getBytes();
    by = s.getBytes();
    is.write(b, 0, b.length);
    filecon.close();
    catch (Exception ioe) {
    System.out.println("EE "+ioe);
    public void showFile(String fileName) {
    try {
    FileConnection fc = (FileConnection)
    Connector.open("file:///C:/" + fileName);
    if (!fc.exists()) {
    throw new IOException("File does not exist");
    InputStream is = fc.openInputStream();
    byte b[] = by;
    int length = is.read(b, 0, b.length);
    stringItem2.setText("Content of " + fileName + ": " +
    new String(b, 0, length));
    System.out.println
    ("Content of " + fileName + ": " + new String(b, 0, length));
    catch (Exception e) {
    /**Handle command events*/
    public void commandAction(Command command, Displayable displayable) {
    /** @todo Add command handling code */
    }

    hi,
    i too got this same security exception.and i followed this below procedure. using this u can get rid of this security exception in the emulator.
    C:\WTK22\wtklib\devices\Nokia_Prototype_SDK_2_0\devices\
    Prototype_2_0_S60_MIDP_Emulator\bin\security_config.xml
    Within the <function name="Read User Data Access"> tag and the <function name="Write User Data Access"> tag you will find a setting that says "untrusted mode=0". Change it to "untrusted mode=4".
    i think to get rid of this pbm in mobile better dont use self signed certificate.without signing the midlet nothing happens other than everytime the permission for reading the file .
    do u have any idea regarding file saving in nokia 6255

  • Problem with FileConnection

    hi friends,
    I am doing project in j2me to transfer images. I am using FileConnection to transfer Image from mobile to Local drive.
    Using file:///SDcard/image.jpg iam reading the image.
    While storing it using file:///D:/Images/image.jpg its giving the below exception
    java.io.IOException: Root is not accessible
    please any one help me...

    It's exactly what I'm saying about: you are limited to the 'roots' which implementation provides to you. In your case they are CFcard,SDcare,root1. (and actually any other folder, which you create under D:\WTK25\appdb\DefaultColorPhone\filesystem)
    There is no possibilty with any J2ME API directly access the Local disks.
    You need to provide some sort of brigde like servlet on application server to be able to transfer the files from you phone (or emulator) to the local discs of computer.
    regarding the transfer of files to servlets see other threads in this forum, like:
    http://forum.java.sun.com/thread.jspa?threadID=5152559

  • Problems with FileConnection and SocketConnection, together

    Hi everybody,
    I use open a fileconnection, and i read some config files... but then when i open a socketConnection my app notifies me that operations related to networking will be made... then i press the Yes command , but the app blocks itself, and no one exception is thrown or catched... my question is, are there any restrictions with the use of the FileConnection , and the socketConnection, together?
    What could be happening?
    thnx in advance!

    wow its confusing....
    its hard to understand....
    i still dont get it, how we know that we now connected to the FTP server??? because all the Connction class (FileConnection,HTTPConnection,SocketConnection) is initalize in variable...
    eg:
    String url = "http://www.server.com:80/com/myServlet";
    HttpConnection c = (HttpConnection)Connector.open(url);
    String url = "socket://www.server.com:80";
    SocketConnection c = (SocketConnection)Connector.open(url);
    do we need thread to always do an connection to server???
    plss can u explain it step by step...
    i really confuse...
    thx before....

  • Problem on appending the text file using FileConnection!!!

    it's in here...
    http://forum.java.sun.com/thread.jspa?threadID=718613&tstart=0
    my apology for double-cross posting..
    thanks much

    attachments
    Attachments:
    julian user not appended.JPG ‏260 KB
    julian user appended.JPG ‏257 KB
    galil mc USER rotation w File writing 5-16-14.vi ‏251 KB

  • File to Essbase Interface Problem

    Hi,
    I have a interface from text file to essbase cube.
    but I have a problem as below;
    Have you any suggestions?
    thanks...
    [2011-12-13T15:43:39.379+02:00] [odi] [WARNING] [] [oracle.odi.agent] [tid: 14] THROW[[
    com.sunopsis.jdbc.driver.file.redir.NotImplementedException
         at com.sunopsis.jdbc.driver.file.redir.FileConnection.rollback(FileConnection.java:57)
         at com.sunopsis.dwg.dbobj.SnpSession.rollbackAllTansactions(SnpSession.java:3218)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2099)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:322)
         at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:224)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:246)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:237)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:794)
         at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:114)
         at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
         at java.lang.Thread.run(Thread.java:662)
    [2011-12-13T15:43:39.379+02:00] [] [ERROR] [ODI-1217] [] [tid: 14] [arg: File_to_Essbase_ANSI] [arg: 53001] [arg: 7000] Session File_to_Essbase_ANSI (53001) fails with return code 7000.[[
    ODI-1226: Step File_to_Essbase_ANSI fails after 1 attempt(s).
    ODI-1240: Flow File_to_Essbase_ANSI fails while performing a Loading operation. This flow loads target table Projects.
    Caused By: java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
         at java.util.Vector.elementAt(Vector.java:427)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.getBindVar(SnpSessTaskSql.java:1860)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execCollOrders(SnpSessTaskSql.java:643)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java:2815)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2515)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:534)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:449)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1954)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:322)
         at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:224)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:246)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:237)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:794)
         at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:114)
         at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
         at java.lang.Thread.run(Thread.java:662)
    ]]

    Murali,
    You get this error when  Adapter specific attributes are missing..
    Maintain Adapter Specific Attributes for business system in Integration directory.
    Select your business system...Then select Service-->Adpater Specific identifiers.
    from right hand window..
    Set Logical System ID(of  R/3 system), R/3System ID and client.
    Let us know if you need more details.
    Nilesh

  • Problem in thread creation

    Hello Frnds,
    i am learning j2me..i am facing some problem in simple thread initilization..
    the code is
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.io.*;
    import javax.microedition.io.*;
    class Process implements Runnable
    private FileConnection MIDlet1;
    private Display display;
    public Process()
    MIDlet1=MIDlet2;
    public void run()
    try
    transmit ();
    catch (Exception error)
    System.err.println(error.toString());
    public void start()
    Thread thread = new Thread(this);
    try
    thread.start();
    catch(Exception e)
    // System.out.println(e);
    private void transmit() throws IOException
    try
    OutputConnection connection = (OutputConnection)Connector.open("file://c:/myfile.txt;append=true", Connector.WRITE );
    OutputStream out = connection.openOutputStream();
    PrintStream output = new PrintStream( out );
    output.println( "This is a test." );
    out.close();
    connection.close();
    catch( ConnectionNotFoundException error )
    catch( IOException error )
    Alert alert = new Alert("Error", error.toString(), null, null);
    alert.setTimeout(Alert.FOREVER);
    alert.setType(AlertType.ERROR);
    display.setCurrent(alert);
    catch(Exception error)
    public class FileConnection extends MIDlet implements CommandListener
    private Command exit, start;
    private Display display;
    private Form form;
    public FileConnection ()
    display = Display.getDisplay(this);
    exit = new Command("Exit", Command.EXIT, 1);
    start = new Command("Start", Command.EXIT, 1);
    form = new Form("Write To File");
    form.addCommand(exit);
    form.addCommand(start);
    form.setCommandListener(this);
    public void startApp() throws MIDletStateChangeException
    display.setCurrent(form);
    public void pauseApp()
    public void destroyApp(boolean unconditional)
    public void commandAction(Command command, Displayable displayable)
    if (command == exit)
    destroyApp(false);
    notifyDestroyed();
    else if (command == start)
    process.start();
    }//middlet ends here
    this code is givin null pinter exception and it does not initialize proocess class..vat is error..plz let me know

    oh ..there was some problem..sending it again
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.io.*;
    import javax.microedition.io.*;
    public class FileConnection extends MIDlet implements CommandListener
    private Command exit, start;
    private Display display;
    private Form form;
    public FileConnection ()
    display = Display.getDisplay(this);
    exit = new Command("Exit", Command.EXIT, 1);
    start = new Command("Start", Command.EXIT, 1);
    form = new Form("Write To File");
    form.addCommand(exit);
    form.addCommand(start);
    form.setCommandListener(this);
    public void startApp() throws MIDletStateChangeException
    display.setCurrent(form);
    public void pauseApp()
    public void destroyApp(boolean unconditional)
    public void commandAction(Command command, Displayable displayable)
    if (command == exit)
    destroyApp(false);
    notifyDestroyed();
    else if (command == start)
    Process process=new Process(this);
    process.start();
    }//middlet ends here
    class Process implements Runnable
    private FileConnection MIDlet;
    private Display display;
    public Process(FileConnection MIDlet)
    this.MIDlet=MIDlet;
    public void run()
    try
    OutputConnection connection = (OutputConnection)
    Connector.open("file://D:/Programs/Hello.txt", Connector.WRITE );
    OutputStream out = connection.openOutputStream();
    PrintStream output = new PrintStream( out );
    output.println( "This is a test." );
    out.close();
    connection.close();
    Alert alert = new Alert("Completed", "Data Written", null, null);
    alert.setTimeout(Alert.FOREVER);
    alert.setType(AlertType.ERROR);
    display.setCurrent(alert);
    catch( ConnectionNotFoundException error )
    Alert alert = new Alert("Error", "Cannot access file.", null, null);
    alert.setTimeout(Alert.FOREVER);
    alert.setType(AlertType.ERROR);
    display.setCurrent(alert);
    catch( IOException error )
    Alert alert = new Alert("Error", error.toString(), null, null);
    alert.setTimeout(Alert.FOREVER);
    alert.setType(AlertType.ERROR);
    display.setCurrent(alert);
    catch(Exception e)
    System.out.println(e);
    public void start()
    Thread thread = new Thread(this);
    try
    thread.start();
    catch(Exception e)
    System.out.println(e);
    }

  • Problem using ContentConnection

    I am trying to create a connection using ContentConnection
    ContentConnection connection = (ContentConnection) Connector.open(url);
    When i run the MIDP i get ClassCast Exception ...... so i used FileConection
    1. FileConnection fc = (FileConnection)Connector.open("file://localhost/root1/sample.png");
    2. DataInputStream ds = fc.openDataInputStream();
    3. byte imageData[];
    4.byte[] b = new byte[1024];
    5. int length = ds.read(b,0,1024);
    6. if (length != -1) {
    7. imageData = new byte[length];
    8. ds.read(imageData);
    9. } else{
    10. ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
    11. int ch;
    12. while ((ch = ds.read()) != -1){
    13. bStrm.write(ch);
    14. }
    15. imageData = bStrm.toByteArray();
    16. bStrm.close();
    17. }
    18. im = Image.createImage(imageData,0,imageData.length);
    This did not solve the problem .... the connection is created but it throws IllegalArgumentException at line 18
    Can anyone help me solve this
    Thanx in advance
    Pushpa

    hi Tom,
    This is how it seems to work. I can import the same flashcard into the new iMovie  then edit the material, then send to file, and choose the file widescreen etc size I want it to be saved as 960 X 540 which to me is similar to widescreen. When I do a check on the size against a widescreen 16 x 9 etc it is the same size (dimensional).
    When I do the same thing in Final Cut Pro X import the file etc I choose the setting (DV anamorphic.) However it still comes out 4 x 3 size with the black columns down the left and right-hand side. My concern is why does iMovie, in my terms format it the way I want it to be formatted? And Final Cut Pro X, which is a more superior package, does not?
    When I was researching this data video DN-60 flash card recorder, I read somewhere that if you are using a Mac computer that the files have to be wrapped in some kind of rapper before they can be read or edited, I do believe by contacting the suppliers of this product that the default recording is in 4 x 3 and it is up to the software that one uses to change the aspect ratio into widescreen. Really not sure what to do now except go back to use iMovie, when I'm trying to move away from it to be more professional in my wedding video production and other works.
    I can import the tape version of the wedding, which is recorded in 16 x 9 and it is perfect when I choose the anamorphic setting to send to file. Your help would be appreciated in this matter, thanking you in advance.

  • Storage Problems!!!URGENT

    Hello everybody
    I am writing an application that has to store information about people (name, surname, address, ... ). What is the best thing to use? Is it RMS or regular file storage?
    I am using the wireless toolkit version 1.0.4 with CLDC 1.0 and MIDP 1.0.
    Apparently, the jsr75 (FileConnection API) is not supported.
    when I tried the regular Connector class with the "file" protocol
    (OutputConnection co = (OutputConnection)Connector.open("file:///f2.xml",Connector.WRITE);), i got the following exception
    javax.microedition.io.ConnectionNotFoundException: The requested protocol does not exist file://f2.xml
    What is the problem?
    Thank you in advance boys.
    Ilo

    it is not OutputConnection but Inputconnection...
    you should read this
    http://developers.sun.com/techtopics/mobility/midp/articles/genericframework/
    for the RMS storage, you can read this good article
    http://www-128.ibm.com/developerworks/library/wi-rms/

  • FileConnection not working

    Hello guys i am developing an multimedia application... using a midlet i am opening an image in the phone file system and i am entering the path to recordstore. till this its working fine and the record store contains the url of the image that i want. but in the next midlet i am getting the url of the image from the recordstore and trying to open the same image for some editing.. but here the file connection is not working... i checked the url retrieved from the recordstore. first i converted it to string and the url is same as that i entered in first midlet.. the problem is that application stops responding when it reaches the fileconnection in the second midlet.. what might be the reason for this???

    Have you set up the correct security permissions for File I/O Access? I know that Java requires you to assign specific access for your programs to do certain things outside the norm. Things like network access require the java program be assigned the correct Network access directive (at least, I had to do this with an old Uni Project) and I'm pretty sure Java ME will have the same issue.
    In Netbeans, i think it is under "Application Descriptor->API Permissions". If you're not using Netbeans, i remember there was a special .ini or .txt file you had to create along with your source code, and include it in your compile or JAR file. Bit rusty, it was a while ago. Might need to google it or pull out any old Sun Java reference manuals.
    If it's not that, where is it dying? In the emulator or the phone itself? If it's the phone, it may be that the phone doesn't support file I/O access (although i think that is pretty unlikely now-a-days). If it's the Emulator, try grabbing a SDK more specific to your phone and giving that a spin, using it's emulator. If the SDK supports Debug-on-device (mine doesn't :( ) you might have an advantage in narrowing down the problem.
    Hope that helps. Good luck!

  • Javadoc problem. To long...

    Hi
    My problems with javadoc in steps.
    1. The commandline becomes to long. (I use a bat-file in dos)
    2. Can't get the packages "listings" to work. My structure are like this.
    the source-files are located at:
    d:\architechture\latest\source\se\company\product\and in this catalog there are a few subcategories where the sourcecode are (.java files).
    The classfiles (jar-files) for the project are located at:
    d:\architechture\latest\deliverables\and a few .jar files.
    Question: How should I write the command to be able to javadoc the files?
    And exactly where should I stand to be able to use the package structure whitch is "se.company.product.XXX" in the source-files.
    3. Extra information.
    I want to generate the javadoc as dynamic as possible, with few direct fileconnections. I want to just do the linkage to catalogs where the files are located.
    NB
    How do I make this to work without trouble with the lengt of the command and so on.
    Thanks
    Tommy Larsson

    Use a Java program and a properties file.
    You can call Javadoc's main method:
    com.sun.tools.javadoc.Main.main(String[]);
    (may vary with VM versions)
    See java.util.Properties aswell - you can load a simple key-based file (like an ini) using the load(InputStream) command.
    myapp.properties:
    #comment
    #example properties file
    NUMARGS=3
    ARG1=aaaaaa
    ARG2=bbbbbb
    ARG3=ccccccode:
    Properties args = new Properties();
    FileInputStream fis = new FileInputStream(myapp.properties);
    args.load(fis);
    fis.close();
    String strnum = args.getProperty("NUMARGS");
    int num = new Integer(strnum).intValue();
    String[] strarr = new String[num];
    for(int i=0; i<num; i++)
         strarr[i] = args.getProperty("ARG"+i);
    com.sun.tools.javadoc.Main.main(strarr);

  • Help on appending a file using FileConnection

    i have a very small MIDlet application in which it just ask the user to input the names, grades and gender and it saves the record into a plain text file...
    I'm using a FileConnection to access the localfiles and im using "PrintStream" to write to the file... it saves the record but my problem is it wont append to the file if the file aready contains a text... it just simply overwrites my text file instead of appending..
    below is the code fragment from my MIDlet Appls:
    //.... some code here...
    private void createTextFile(String name, String score, String grade) throws IOException{
             FileConnection fc=(FileConnection)Connector.open("file:///TangoFox/ThisIsATest.txt");
             OutputStream os=(OutputStream)fc.openOutputStream();
             PrintStream printStream=new PrintStream(os);
             form.append("writing...");
              printStream.println("\n"+name+"\t"+score+"\t"+grade);
              if(!fc.exists())
                 fc.create();
              if(printStream!=null)
                 printStream.close();            
              if(fc!=null)
                fc.close();
    //... some code here...-any idea on how to make it append if the file already contains values?
    thanks much

    Hi,
    Have you tried:
    fileConnection.openOutputStream(fileConnection.fileSize());or
    fileConnection.openOutputStream(Long.MAX_VALUE);For details see javadocs.

  • Problems on Saving a text file

    the "Java Programming" forum is more active compare to "CLDC-MIDP" and "WTK" forum that's why I posted my problem here just case in MIDP programmer dropped by.
    My problem is my phone (Nokia 6260) contains MIDP2.0, the problem is, it has no JSR-75/File Connection API... my application is runs perfectly on my WTK2.2 because it has a JSR-75 jar file...
    but it wont run on my Nokia 6260 phone because of FileConnection API is missing... my question is, is it possible to install the JSR75 on my mobile Nokia6260 phone?
    again, my apology for posting my grievance here...
    thank you so much...

    You can do it by upgrading your firmware .
    If there is upgraded firmware supporting JSR75 then it might solve your problem.

  • Alternative to FileConnection ?

    Hi all.
    I'm writing a MIDlet in which I'm trying to access the file system of my iPAQ hx4700. Sadly the iPAQ doesn't support the JSR-75, so I can't use the FileConnection class to access the file system. I have determined this by doing the following:
    protected void paint(Graphics g)
    String v = System.getProperty(
    "microedition.io.file.FileConnection.version" );
         if( v != null ){
         g.drawLine(0, 0, 20, 20);
         } else {
         g.drawRect(0, 0, 100, 100);
    And sadly the MIDlet draws the rectangle
    Is there another way to access a file. The file I'm trying to access is a gif image that I would like to draw on the screen of the iPAQ.
    thanks in advance

    It's not the displaying of the image that is the problem is more opening and reading the contents of an image file on the PDA's file system

Maybe you are looking for

  • How to find out that an art item has spot color using script?

    Hi all, I have a number of art items on a document, some of them are filled with spot colors and some of them are with process color. Is there any method by which I can find out which color type(spot or process) is applied to the selected art item? T

  • How to check Data Source extraction Logic

    Hi Experts Please explain me in details steps how/where can i check the logic of data sources We have data sources based on 1) Custom data source based on Function Module  (Where can i check the code/logic....) 2) Standard Business Content Data sourc

  • Why can't I upload and how do I fix this?

    I have currently had some problems with my broswer, I ended up unistalling firefox, and reinstalling it several times. Once my initial problem was fixed I went on with what I was trying to do which was uploading files for my online school. Now for so

  • "Incredible dancing footers" driving me INSANE!!!

    I'm working on my site, being very meticulous when it comes to making sure all the layout parts are the same size, etc. When I run through my pages in iWeb, everything looks good - the headers and footers appear stable when switching between pages. H

  • Where to download Siebel UCM?

    I cant find where I can download it from edelivery. This thread Where to download Siebel UCM? says download it from edelivery i.e. Siebel Business Applications as pasted below. However, I do not find any "Siebel Applications" listed there. You can do