If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > JAVA > j2me append=true error, J2ME need help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-16-07, 21:40
YawBoon YawBoon is offline
Registered User
 
Join Date: Jun 2006
Posts: 5
Red face j2me append=true error, J2ME need help

I wanna output multiple answer to the text file i create in the root location.

but if i put

try{
String uri = "file:///root1/myfile2.txt;append=true";
OutputConnection connection = (OutputConnection)
Connector.open(uri, Connector.WRITE );
OutputStream out = connection.openOutputStream();
printStream output = new PrintStream( out );
output.print( "Answer 1 is:\n\n" + list.getString(x)); out.close();
connection.close();
}

the append=true will cause error:java.io.IOException:

if i remove the append=true , i can save the data....but only one data is save to the text file each time.
Reply With Quote
  #2 (permalink)  
Old 05-17-07, 07:52
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
One of my initial thoughts is...
Why are you writing to a text file?
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 05-18-07, 09:16
BettingSherlock BettingSherlock is offline
Registered User
 
Join Date: May 2007
Posts: 78
"file:///root1/myfile2.txt;append=true"

The whole string is considered to be a filename, and as such it is not a valid filename.

Check the documentation, at some point you can tell the method you use to append. I usually use a filewriter and you can set an append flag when creating the file object. Don't know with connector and outputstream but should be simular.

http://java.sun.com/j2se/1.4.2/docs/...ileWriter.html
Method: FileWriter(String fileName, boolean append)

if the link doesn't work then google "filewriter java"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On