Saving and loading files

View: New views
6 Messages — Rating Filter:   Alert me  

Saving and loading files

by YesFuture :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello, i've got some serious problem. i found this save method and tryed to use in my program.I'm trying to create simple mobile notebook with save and load functions:



private void saveFile() {

       try {

           



           byte data[] = textBox.getString().getBytes();





           FileConnection fconn = (FileConnection)Connector.open("file:///A.txt", Connector.READ_WRITE);

           if (!fconn.exists()) {

               fconn.create();



           }

           OutputStream ops = fconn.openOutputStream();

           ops.write(data);

           ops.close();

           fconn.close();

       }

       catch (IOException ioe) {

          System.out.println("IOException: " + ioe.getMessage());

       }

       catch (SecurityException se) {

           System.out.println("Security exception:" + se.getMessage());

       }

   }



But when i'm trying to save, the file don't save. I tried different directories , but nothing changed. Could you help me please?





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Saving and loading files

by phillipC :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't know much about Java because I'm in process of learning it, but are you sure this statement is correct "file:///A.txt" ?  Maybe instead of you using forward slash, try back slash, and are u sure there are three slashes?

YesFuture wrote:
Hello, i've got some serious problem. i found this save method and tryed to use in my program.I'm trying to create simple mobile notebook with save and load functions:



private void saveFile() {

       try {

           



           byte data[] = textBox.getString().getBytes();





           FileConnection fconn = (FileConnection)Connector.open("file:///A.txt", Connector.READ_WRITE);

           if (!fconn.exists()) {

               fconn.create();



           }

           OutputStream ops = fconn.openOutputStream();

           ops.write(data);

           ops.close();

           fconn.close();

       }

       catch (IOException ioe) {

          System.out.println("IOException: " + ioe.getMessage());

       }

       catch (SecurityException se) {

           System.out.println("Security exception:" + se.getMessage());

       }

   }



But when i'm trying to save, the file don't save. I tried different directories , but nothing changed. Could you help me please?





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@mobility.netbeans.org
For additional commands, e-mail: users-help@mobility.netbeans.org

Saving and loading files

by steve204 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am having a similar problem. I am trying to write a file using the DefaultColorPhone emulator in the Windows home vista environment. I believe the file is supposed to show in the root1 directory but can't get it to work.



Are you seeing the problem using the emulator too or on the phone itself?





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Saving and loading files

by YesFuture :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i see this problem both on phone and on emulator  :(  and i've just found "file:///A.txt" there was an explanation but i dont remember that   :(





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Saving and loading files

by steve204 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not sure what you mean when you say "i've just found "file:///A.txt" there was an explanation but i dont remember that".



Which environment are you running the emulator in?





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Saving and loading files

by steve204 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If I run with a value for the filename of: "file:///wc.txt"

I get this error: java.lang.IllegalArgumentException: Root is not specified



If I run with a value of "file:///root1/wc.txt"

I get this in the Netbeans output window:

Warning: To avoid potential deadlock, operations that may block, such as

 networking, should be performed in a different thread than the

 commandAction() handler.



In the emulator, I get the "Is it OK to update your files?" message but the emulator just hangs here - regardless of whether I click Yes or No...



Again, this is in the window vista home OS.





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...