This discussion is archived
1 Reply Latest reply: Oct 4, 2010 10:35 AM by 802951 RSS

FileConnection API JSR 75

762917 Newbie
Currently Being Moderated
I am trying this api on the WTK emulator and ther is an issue with show the valid roots and dir and files inside the roots.
In the emulator there is one default root, this one:

"/<toolkit>/appdb/DefaultColorPhone/filesystem/root1/"

inside this root, there is one dir and one file, if run my code it shows well the root and its content. But if i create manually a dir or a file in the root, those arent show.

I havent do a test on a real device but in the emulator it didnt work.

What could be the problem ?

this is my code:
try {
         FileConnection fc = (FileConnection)
            Connector.open("file:///root1/");
                  System.out.println
            ("List of files and directories under root1:");
         Enumeration filelist = fc.list("*", true);
         while(filelist.hasMoreElements()) {
            String fileName = (String) filelist.nextElement();
            fc = (FileConnection)
               Connector.open("file:///root1/" + fileName);
            if(fc.isDirectory()) {
               System.out.println("\tDirectory Name: " + fileName);
            } else {
               System.out.println
                  ("\tFile Name: " + fileName +
                   "\tSize: "+fc.fileSize());
            }

         }
         fc.close();
      } catch (IOException ioe) {
         System.out.println(ioe.getMessage());
      }
Thanx

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points