• 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)
      // Always check whether the file or directory exists.
      // Create the file if it doesn't exist.
      if(!filecon.exists()) {
         System.out.println("CREATING FILE");
         System.out.println("CREATED FILE");
   } catch(IOException ioe) {
   System.out.println("ERROR CREATING FILE");
1 Solution
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.

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