FeaturesPluginsDocs & SupportCommunityPartners

NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Saving and loading files

 
Post new topic   Reply to topic    NetBeans Forums -> Java ME Users
View previous topic :: View next topic  
Author Message
YesFuture



Joined: 17 Mar 2009
Posts: 2
Location: Lithuania,Kaunas

PostPosted: Tue Mar 17, 2009 3:54 pm    Post subject: Saving and loading files Reply with quote

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?
Back to top
View user's profile Send private message Visit poster's website
phillipC
Posted via mailing list.





PostPosted: Tue Mar 17, 2009 4:44 pm    Post subject: Saving and loading files Reply with quote

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:
Quote:

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?












--
View this message in context: http://www.nabble.com/Saving-and-loading-files-tp22562337p22563340.html
Sent from the Netbeans Java Mobile Edition/ME Users (Mobility) mailing list archive at Nabble.com.
Back to top
steve204



Joined: 19 Mar 2009
Posts: 3

PostPosted: Thu Mar 19, 2009 1:18 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
YesFuture



Joined: 17 Mar 2009
Posts: 2
Location: Lithuania,Kaunas

PostPosted: Thu Mar 19, 2009 1:20 pm    Post subject: Reply with quote

i see this problem both on phone and on emulator Sad and i've just found "file:///A.txt" there was an explanation but i dont remember that Sad
Back to top
View user's profile Send private message Visit poster's website
steve204



Joined: 19 Mar 2009
Posts: 3

PostPosted: Thu Mar 19, 2009 3:10 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
steve204



Joined: 19 Mar 2009
Posts: 3

PostPosted: Thu Mar 19, 2009 7:06 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java ME Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB