B4J Question B4J jRandomAccessFile - How to Clear ?

Discussion in 'B4J Questions' started by focus330, Apr 9, 2019.

  1. focus330

    focus330 Member Licensed User


    I'm trying to clear all contents of a RandomAccessFile but I don't understand how to do it.
    I try simply deleting file, but, until the app is open, there is no permission to do it, also closing the raf before delete.

    I tried also with javaobjects with method 'setLenght' but isn't recognized.

    Is it possible to clear a raf ?

    Thanks for suggestions.
  2. Erel

    Erel Administrator Staff Member Licensed User

    Raf.Close + delete should work. What is locking the file?
  3. focus330

    focus330 Member Licensed User


    I don't know what happened yesterday.
    Also exiting from b4j and restarting it, in debugging mode and also in release mode, the delete instruction was always False
    But with explorer , with the app closed, I could delete the fiie. Of course, with the app opened, I coudn't do it. Permissions were OK.

    Today, after the restart of the PC 'file.delete' works correctly.
    Then it seems that one istance of raf.initialize remains attached.
    The same, it is strange for me that yesterday with explorer I could delete the file and with code I didn't.

    Probably an occasional event that I don't understand. To be sure, I'll release the app to the user writing an empty list instead of deleting file.
  4. focus330

    focus330 Member Licensed User

    My code now is
    Dim Listazz as list
    EsitoBool = 
    If EsitoBool = False Then
    End If
  5. Erel

    Erel Administrator Staff Member Licensed User

    Tip: Call XUI.SetDataFolder once when your program starts and use XUI.DefaultFolder in all places. This will save the need to include the app name every time.

    You can write an empty file with File.WriteString(XUI.DefaultFolder, "log_apk", "")
    Harris likes this.
  6. focus330

    focus330 Member Licensed User

    Thanks Erel. Useful.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice