Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User Veron_4's Avatar
    Join Date
    Dec 2009
    Posts
    5
    Hi, could I have some help on this J2ME application. I am trying to read a CSV file and then write into it by either editing a line or inserting a new line.
    This is my current test code.

    FileConnection filecon =
    (FileConnection)Connector.open("file:///root1/test.csv",Connector.READ_WRITE);

    if(!filecon.exists()) {
    filecon.create();
    }
    OutputStream os = filecon.openOutputStream();
    PrintStream output=new PrintStream(os);
    output.println("This is a test" + "," + "file");
    os.close();



    However, I noticed that when I run my J2ME application, a new temp folder is being created each time so a new test.csv is being created each time. This way, I am not being able to access the test.csv file I had put in the root folder which is here: "j2mewtk\2.5.2\appdb\temp.DefaultColorPhone116\filesystem\root1"

    Please help me, thanks a lot in advance
    JEEVA
    Last edited by Veron_4; 2009-12-23 at 06:18.

  2. #2
    Super Contributor ingsaurabh's Avatar
    Join Date
    Apr 2009
    Posts
    572
    your path looks suspecting what is temp. I never found it any files system both in WTK 2.5 and netbeans 5.5.1

    "j2mewtk\2.5.2\appdb\temp.DefaultColorPhone116\filesystem\root1"
    I found this

    "appdb\DefaultColorPhone\filesystem\root1"
    Regards,
    Saurabh

  3. #3
    Registered User Veron_4's Avatar
    Join Date
    Dec 2009
    Posts
    5
    Hi, thanks for trying to help. In the j2mewtk\2.5.2\appdb folder, a new "temp.DefaultColorPhoneXXX" folder is created. XXX refers to a number which increases by 1 each time I run the application

    So a new 'test/csv' file is created in the
    "j2mewtk\2.5.2\appdb\temp.DefaultColorPhone116\filesystem\root1"
    folder instead of looking at the
    "j2mewtk\2.5.2\appdb\DefaultColorPhone\filesystem\root1"
    folder where the original CSV file is located.

    You won't be able to see the temp folder in your PC as it's only created during runtime

  4. #4
    Super Contributor ingsaurabh's Avatar
    Join Date
    Apr 2009
    Posts
    572
    Ok it well I used the 2.5.2 earlier but never found such issues my luck afaik its buggy u must try for final release i.e. 2.5 only and try one thing more place any file in your filesystem manually and try to access it through your code if you succed in it then try for writing it
    Regards,
    Saurabh

  5. #5
    Registered User Veron_4's Avatar
    Join Date
    Dec 2009
    Posts
    5
    I did try to manually create the csv file and access it. But problem is that it keeps creating a new one

  6. #6
    Super Contributor ingsaurabh's Avatar
    Join Date
    Apr 2009
    Posts
    572
    PHP Code:
    FileConnection fc null;
                
    InputStream ips null;
                try
                {
                    
    String songTitle theFile.substring(theFile.lastIndexOf('/')+1,theFile.lastIndexOf('.'));
                    
    fields2[1].setText(songTitle.toUpperCase());
                    
    fields2[1].invalidating();
                    
    titleText songTitle;
                    
    saved true;
                    
    fc = (FileConnection)Connector.open("file:///" theFile Connector.READ_WRITE);
                    
    ips fc.openInputStream();
                    
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    
    byte[] buffer = new byte[(int)fc.fileSize()];
                    while (
    true)
                    {
                        
    int bytesRead ips.readbuffer0buffer.length );
                        if (
    bytesRead == -1)
                            break;
                        
    byteArrayOutputStream.writebuffer0bytesRead );
                    }
                    
    byteArrayOutputStream.flush();
                    
    byte[] result byteArrayOutputStream.toByteArray();
                    
    byteArrayOutputStream.close();
                    
    String resultString = new String(result); 
    try this code please edit it some its long code I gave you only reading the file try this
    Regards,
    Saurabh

  7. #7
    Registered User Veron_4's Avatar
    Join Date
    Dec 2009
    Posts
    5
    I tried that, it does the same thing. A new temporary folder is being created instead of looking for the file I have.

  8. #8
    Super Contributor ingsaurabh's Avatar
    Join Date
    Apr 2009
    Posts
    572
    then I suspect its your toolkit problem change it and gave a try
    Regards,
    Saurabh

  9. #9
    Registered User Veron_4's Avatar
    Join Date
    Dec 2009
    Posts
    5
    Sorry, still not working.. Everytime I startup the application, it automatically goes into the storage root and creates a new temp folder.

    Is there any way, I can change this?

  10. #10
    Super Contributor ingsaurabh's Avatar
    Join Date
    Apr 2009
    Posts
    572
    Quote Originally Posted by Veron_4 View Post
    Sorry, still not working.. Everytime I startup the application, it automatically goes into the storage root and creates a new temp folder.

    Is there any way, I can change this?
    k try this ,this is my last resort otherwise I cant figure out what the problem is
    PHP Code:
    FileConnection filecon =
    (
    FileConnection)Connector.open("file:///root1/test/test.csv",Connector.READ_WRITE);

    if(!
    filecon.exists()) {
    filecon.create();
    }
    else
    {
    filecon.delete();
    filecon.create();
    }
    OutputStream os filecon.openOutputStream();
    PrintStream output=new PrintStream(os);
    output.println("This is a test" "," "file");
    os.close(); 
    and create test folder in your root1 directory
    Regards,
    Saurabh

Similar Threads

  1. Theme Studio 3.1 not creating themes
    By zemm in forum Themes/Carbide.ui
    Replies: 11
    Last Post: 2008-10-18, 08:41
  2. Reading and writing to file
    By rkuppala in forum Symbian C++
    Replies: 6
    Last Post: 2008-03-13, 09:59
  3. File reading & writing help, wav file redaing help
    By shubhamlahoti in forum Mobile Java General
    Replies: 6
    Last Post: 2007-06-27, 09:07
  4. reading from a file and writing to another file
    By ibraheemJazba in forum Symbian C++
    Replies: 3
    Last Post: 2007-03-08, 11:50
  5. Reading and Writing to file
    By rkuppala in forum Symbian C++
    Replies: 1
    Last Post: 2004-08-03, 15:17

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved