hi,
i found a lot of examples how to read data from one file but i can't understand how i do it by of InputStream and method read.
someone could give me a example ??
Printable View
hi,
i found a lot of examples how to read data from one file but i can't understand how i do it by of InputStream and method read.
someone could give me a example ??
Hello stein,
here's an example (under the 'Solution' title):
[url]http://wiki.forum.nokia.com/index.php/KIJ000081_-_Reading_resources_from_a_JAR_file[/url]
Regards,
r2j7
but now i have another problem case i can't access to the file i use this url = "file:///C:/myfile.txt"; but exception tells me that i have no permission to write there, can explain me how work directories on n70, i see a tutorial but only specifies the mai drive don´t talk about the directories that can be used
ty,
Hello stein,
Below's a quote from:
[url]http://www.forum.nokia.com/info/sw.nokia.com/id/de0f933c-0bd3-4143-b62a-ab867a43409a/MIDP_FileConnection_API_Developers_Guide_v2_0_en.zip.html[/url]
[QUOTE]
An example of a typical file URL in a S60 device looks as follows:
file:///C:/data/Images/Image(001).jpg
[/QUOTE]
Based on the above, try something like:
C:/data/myfile.txt
Regards,
r2j7
ty for your help, but i try what you suggest and don´t work, my code to save info on file:
[CODE] String url = "file:///c:/nokia/myfile.txt";
FileConnection conn = null;
try {
System.out.println("\na guardar informação-------------------------------------->1\n");
conn = (FileConnection) Connector.open( url,Connector.READ_WRITE );
if( conn.exists()==false )
conn.create();// create the file
OutputStream out = conn.openOutputStream();
for (int i = 0; i < horaMiranda.length; i++) {
out.write(this.horaMiranda[i].toString().getBytes());
System.out.println("\na guardar informação-------------------------------------->2\n");
}
conn.close();
} catch( IOException e ){
System.out.println("\nERRO\n");
} catch( SecurityException e ){
System.out.println("\nNo permissions to write \n");
}[/CODE]
can someone tell me what is wrong for the code give me exception and don´t let me write on file..
ty,
Hello stein,
[QUOTE]String url = "file:///c:/nokia/myfile.txt";[/QUOTE]
Did you try using
String url = "file:///C:/data/myfile.txt";
or
String url = "file:///C:/Data/myfile.txt";
?
Regards,
r2j7
ty for help.
i try what you sad but don't works, i don't no that is important but i use s60 3rd edition sdk fp2 with s60 emulator. i have to change any option on emulator?
[QUOTE=stein;396205]ty for help.
i try what you sad but don't works, i don't no that is important but i use s60 3rd edition sdk fp2 with s60 emulator. i have to change any option on emulator?[/QUOTE]
If you use emulator, try to put your file to the root folder of the emulator. For me it is
C:\Programme\Java\WTK25\appdb\DefaultColorPhone\filesystem\root\
Then you call
[CODE]conn = (FileConnection) Connector.open( "file:///root/myfile.txt",Connector.READ_WRITE )[/CODE]
Greetings
Ben
i follow your indications, but don´t work still say that i have no permission, whe i put the directory root give me a error but wasn't error of permission.
i use the listroot and the only directories that listed are:
Phone memory/
C:
i already add the options on java platform manager for read and write.
i need change any option, to permit write and read files?
any ideia to fix the problem??
i really need help? i want to learn how works with files.
i had done everything and can't write the file case i don't have permission. i really need help?
You have to set the permissions in your jad file:
[CODE]
MIDlet-Permissions: javax.microedition.io.Connector.file.read, javax.microedition.io.Connector.file.write
[/CODE]
Greetings
Ben