• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3330
  • Last Modified:

Writing to a file - java.lang.IllegalArgumentException: Root is not specified

I am trying to write to a file on a J2ME emulator but I keep getting the error within the subject.  I have pasted my code.  Thanks

      FileConnection filecon = (FileConnection)
         Connector.open("file:///myfile.txt");
      // Always check whether the file or directory exists.
      // Create the file if it doesn't exist.
      if(!filecon.exists()) {
         System.out.println("CREATING FILE");
         filecon.create();
         System.out.println("CREATED FILE");
      }
      filecon.close();
   } catch(IOException ioe) {
   System.out.println("ERROR CREATING FILE");
   }
           }
0
vandy02
Asked:
vandy02
1 Solution
 
CodeFishCommented:
When you run the midlet, look at the output for the line "running with storage root ..."  Go to that directory in Explorer. You should see a folder called "filesystem" in that folder you should see a directory like "root1" If that is the case you should specify "Connector.open("file:///root1/mynewfile.txt");
I'm using NetBeans. Eclipse may differ slightly.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now