Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2006
    Posts
    5

    Red face Unanswered: 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.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    One of my initial thoughts is...
    Why are you writing to a text file?
    George
    Home | Blog

  3. #3
    Join Date
    May 2007
    Posts
    80
    "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"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •