Package totalcross.io

Class File

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, FileStates

    public class File
    extends RandomAccessStream
    implements FileStates
    File represents a file or directory.

    Note that writing to a storage card can be 5x slower than writing to the main memory.

    Here is an example showing data being read from a file:

     File file = new File("/temp/tempfile", File.READ_WRITE);
     byte b[] = new byte[10];
     file.readBytes(b, 0, 10);
     file.close();
     file = new File("/temp/tempfile"); // opens in DONT_OPEN mode
     file.delete();
     
    When creating a new file, you may start the path using the alias "device/", which evaluates to the platform's base user directory:
    • PalmOS, WinCE and iPhone - "/" (root)
    • BlackBerry - "/store/home/user/"
    • Java - "/" (current directory)
    • Win32 - "/" (root of the current drive)
    • iOS - "/private/var/" in a installation using .deb (on a jailbroken device) or in the documents folder of the application in a installation using .ipa
    • Android - "/data/data/totalcross.app.<mainclass name>" or "/data/data/totalcross.app.<application id> if using single package
    The alias is ALWAYS relative to the built in storage, regardless of the value passed to the argument slot.
    On iOS and Android, if you don't specify a path, the file will be open in device/ path.
    • Constructor Summary

      Constructors 
      Constructor Description
      File​(java.lang.String path)
      Opens a file with the given path and mode=DONT_OPEN and slot=-1.
      File​(java.lang.String path, int mode)
      Creates a file with the given path, mode and slot=-1.
      File​(java.lang.String path, int mode, int slot)
      Deprecated.
      TotalCross 2 no longer uses slot
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      int chmod​(int mod)
      Applies the given permissions to this file.
      void close()
      Closes the file.
      static void copy​(java.lang.String src, java.lang.String dst)
      A handy method to call copyTo creating two File instances and closing them.
      void copyTo​(File dest)
      Copies the current file to the given one.
      void createDir()
      Recursively creates a directory that is represented by the current file.
      void delete()
      Deletes the file or directory (which must be empty).
      static void deleteDir​(java.lang.String dir)
      Deletes a directory and all its subdirectories and files.
      boolean exists()
      Returns true if the file exists and false otherwise.

      Example:
      protected void finalize()  
      void flush()
      Flushes a file.
      static File getAppSpecificDir​(java.lang.String type, java.lang.String dirName)
      Returns a file object with a path writable by the application on the device storage.
      int getAttributes()
      Gets this file attributes.
      static java.lang.String getCardSerialNumber​(int slot)
      Returns the card serial number for the given slot.
      static File getCardVolume()
      Returns the volume File for the Windows CE and Pocket PC, and BlackBerry devices.
      File getParent()
      Returns the file's parent, or null if its the root.
      java.lang.String getPath()
      Return the file's path passed in the constructor.
      int getPos()
      Returns the current offset in this stream.
      int getSize()
      Returns the size of the file in bytes.
      int getSlot()
      Returns the slot number passed in the constructor, or -1 if no slot was given.
      Time getTime​(byte whichTime)
      Retrieves the specified time attribute of the opened file - cannot be used with DONT_OPEN.
      JDK - If the object state and the received argument are valid, it will always return the time of the last modification.
      static boolean isCardInserted​(int slot)
      Can be used to verify if a card is inserted into the given slot.
      boolean isDir()
      Returns true if the file is a directory and false otherwise.
      boolean isEmpty()
      If this is a file, returns true if the file has 0 bytes.
      java.lang.String[] listFiles()
      Lists the files contained in a directory.
      static java.lang.String[] listFiles​(java.lang.String dir)
      Returns a recursive list of all files inside the given directory (including it).
      static java.lang.String[] listFiles​(java.lang.String dir, boolean recursive)
      Lists all the files in the specified directory, and also the files in the subdirectories if recursive is true.
      static java.lang.String[] listRoots()
      List the root drives.
      static void move​(java.lang.String src, java.lang.String dst)
      A handy method to call moveTo creating two File instances and closing them.
      void moveTo​(File dest)
      Moves the current file to the given one (the original file is deleted).
      byte[] read()
      Deprecated.
      byte[] readAndClose()
      Deprecated.
      byte[] readAndDelete()
      Deprecated.
      int readBytes​(byte[] b, int off, int len)
      Reads bytes from the stream.
      void rename​(java.lang.String path)
      Renames the file.
      void setAttributes​(int attr)
      Sets the attributes of the opened file - cannot be used with DONT_OPEN.
      Platform specific notes: JDK - This method has no effect on any file when running on JDK, it only checks if the object state and the received argument are valid.
      void setPos​(int pos)
      Sets the file pointer for read and write operations to the given position.
      void setPos​(int offset, int origin)
      Sets the file pointer for read and write operations to a new position defined by adding offset to a reference position specified by origin.
      void setSize​(int newSize)
      Sets the file size, growing the size or truncating it.
      void setTime​(byte whichTime, Time time)
      Sets the time attribute of the opened filed - cannot be used with DONT_OPEN or READ_ONLY.
      Platform specific notes: JDK - This method has no effect on any file when running on JDK, it only checks if the object state and the received arguments are valid.
      void writeAndClose​(byte[] bytes)
      Deprecated.
      int writeBytes​(byte[] b, int off, int len)
      Writes bytes to the stream.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • path

        protected java.lang.String path
        The path that represents this file
      • ATTR_READ_ONLY

        public static final int ATTR_READ_ONLY
        Used in the getAttributes and setAttributes method. These values are platform independent. Palm specific: Avoid using this attribute on a file located on the Built-in storage, because some devices do not allow this attribute to be changed after it is first set. This results in a read-only file that cannot be changed or deleted.
        See Also:
        setAttributes(int), getAttributes(), Constant Field Values
      • winceVols

        public static java.lang.String[] winceVols
        These are the volumes that getCardVolume search to find the available one.

        To access the card in Android devices, prefix the path with /sdcard. Be sure that the sdcard is NOT MOUNTED, otherwise your application will not have access to it.
        See Also:
        getCardVolume()
      • DIRECTORY_PICTURES

        public static final java.lang.String DIRECTORY_PICTURES
        See Also:
        Constant Field Values
      • DIRECTORY_DOCUMENTS

        public static final java.lang.String DIRECTORY_DOCUMENTS
        See Also:
        Constant Field Values
      • DIRECTORY_DOWNLOADS

        public static final java.lang.String DIRECTORY_DOWNLOADS
        See Also:
        Constant Field Values
    • Method Detail

      • isCardInserted

        public static final boolean isCardInserted​(int slot)
                                            throws IllegalArgumentIOException
        Can be used to verify if a card is inserted into the given slot. Only works on Palm OS and Android devices. In all other platforms, always returns true.
        Parameters:
        slot - The slot number, or -1 to use the last slot number (which, in most devices, will be the only slot available).
        Throws:
        IllegalArgumentIOException
        Since:
        SuperWaba 5.52
      • close

        public void close()
                   throws IOException
        Closes the file.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        IOException - If a file is closed more than once,
      • flush

        public void flush()
                   throws IOException
        Flushes a file. This causes any pending data to be written to disk. Calling this method too much may decrease the performance. Has no effect on JavaSE.
        Throws:
        IOException
      • createDir

        public final void createDir()
                             throws IOException
        Recursively creates a directory that is represented by the current file. The file must have been open in DONT_OPEN mode (remember that the constructor File(String) already opens the file in DONT_OPEN mode).
        Throws:
        IOException - If the file was closed, or if it was open in anything else than DONT_OPEN, or if the directory already exists, or if the directories could not be created.

        Example:

         new File("/my/new/recursive/folder").createDir();
         
      • delete

        public final void delete()
                          throws FileNotFoundException,
                                 IOException
        Deletes the file or directory (which must be empty). The file is automatically closed before it is deleted. The file could have been opened in any of the available modes, except READ_ONLY. Example:
         new File("/my/file.c").delete();
         
        Throws:
        FileNotFoundException
        IOException
      • exists

        public final boolean exists()
                             throws IOException
        Returns true if the file exists and false otherwise.

        Example:
         if (new File("dummy.txt").exists())
            ...
         
        Throws:
        IOException
      • getSize

        public final int getSize()
                          throws IOException
        Returns the size of the file in bytes. If the file is a directory (ends with slash, not backslash), it returns the amount of free space in bytes of the card/file system (also works on JDK 1.6 and above).

        If the total amount is greater than 2 GB, 2 GB is returned. In other cases, if the file is not opened, an exception will be thrown.

        Examples:
         int freeSpace;
         if (Settings.platform.equals("Win32") || Settings.platform.equals("Java"))
            freeSpace = new File("c:\\").getSize();
         else if (Settings.platform.equals("PalmOS"))
            freeSpace = new File("\\", 1).getSize(); // hidden volume
         else
            freeSpace = new File("\\").getSize(); // WinCE and Posix
         
        Throws:
        IOException
      • getPath

        public java.lang.String getPath()
        Return the file's path passed in the constructor.
      • isDir

        public final boolean isDir()
                            throws IOException
        Returns true if the file is a directory and false otherwise. The file must have been open in DONT_OPEN mode.
        Throws:
        IOException
      • listFiles

        public final java.lang.String[] listFiles()
                                           throws IOException
        Lists the files contained in a directory. The strings returned are the names of the files and directories contained within this directory. Paths are suffixed by a slash.
        Throws:
        IOException
      • isEmpty

        public final boolean isEmpty()
                              throws IOException
        If this is a file, returns true if the file has 0 bytes. If this is a folder, returns true if there are no files nor folders inside of it.
        Throws:
        IOException
        Since:
        TotalCross 1.27
      • readBytes

        public final int readBytes​(byte[] b,
                                   int off,
                                   int len)
                            throws IOException
        Description copied from class: Stream
        Reads bytes from the stream. Returns the number of bytes actually read or -1 if the end of the stream was reached. (if applicable to the stream)
        Specified by:
        readBytes in class Stream
        Parameters:
        b - the byte array to read data into
        off - the start position in the array
        len - the number of bytes to read
        Throws:
        IOException
      • rename

        public final void rename​(java.lang.String path)
                          throws IllegalArgumentIOException,
                                 IOException
        Renames the file. You must give the full directory specification for the file, to keep compatibility between all platforms. WinCE platform lets you move a file using rename, while Palm OS does not let you move the file. File is automatically closed prior to renaming. After this operation, this File object is invalid. Cannot be used in READ_ONLY mode.
        Parameters:
        path - the new name of the file.
        Throws:
        IllegalArgumentIOException
        IOException
      • getPos

        public int getPos()
                   throws IOException
        Description copied from class: RandomAccessStream
        Returns the current offset in this stream.
        Overrides:
        getPos in class RandomAccessStream
        Returns:
        the offset from the beginning of the stream, in bytes, at which the next read or write occurs.
        Throws:
        IOException - if an I/O error has occurred.
      • setPos

        public final void setPos​(int pos)
                          throws IOException
        Sets the file pointer for read and write operations to the given position. The position passed is an absolute position, in bytes, from the beginning of the file. To set the position to just after the end of the file, you can call:
         file.setPos(file.getSize());
         
        Note: if you plan to change the file size using setPos, you must write something on the new size to effectively change the size. For example, on some devices if you call setPos and then read (assuming that the new pos is past the end of the file, the read method will fail. Here's a code that will change the size for sure:
         private static byte[] zeros = new byte[4096];
         
         public void setSize(int newSize)
         {
            int size = f.getSize();
            f.setPos(newSize - 1); // note: setPos(1) makes the file 2 bytes long (0, 1)
            f.setPos(size);
            for (int dif = newSize - size, n = 0; dif > 0; dif -= n)
               n = f.writeBytes(zeros, 0, dif > zeros.length ? zeros.length : dif);
         }
         
        Specified by:
        setPos in class RandomAccessStream
        Parameters:
        pos - the offset position, measured in bytes from the beginning of the file, at which to set the file pointer.
        Throws:
        IOException - if pos is negative or if an I/O error occurs.
      • setPos

        public final void setPos​(int offset,
                                 int origin)
                          throws IOException
        Description copied from class: RandomAccessStream
        Sets the file pointer for read and write operations to a new position defined by adding offset to a reference position specified by origin.
        Specified by:
        setPos in class RandomAccessStream
        Parameters:
        offset - number of bytes to offset from origin.
        origin - position from where offset is added. It is specified by one of the SEEK_* constants.
        Throws:
        IOException - if the new position is negative or if an I/O error occurs.
      • writeBytes

        public final int writeBytes​(byte[] b,
                                    int off,
                                    int len)
                             throws IOException
        Description copied from class: Stream
        Writes bytes to the stream. Returns the number of bytes actually written or throws an IOException if an error prevented the write operation from occurring.
        Specified by:
        writeBytes in class Stream
        Parameters:
        b - the byte array to write data from
        off - the start position in the byte array
        len - the number of bytes to write
        Returns:
        the number of bytes actually written
        Throws:
        IOException
      • setAttributes

        public final void setAttributes​(int attr)
                                 throws IllegalArgumentIOException,
                                        IOException
        Sets the attributes of the opened file - cannot be used with DONT_OPEN.
        Platform specific notes:
        • JDK - This method has no effect on any file when running on JDK, it only checks if the object state and the received argument are valid.
        • BLACKBERRY - Supports only ATTR_HIDDEN and ATTR_READ_ONLY.
        • LINUX, IPHONE, and ANDROID - The attributes ATTR_HIDDEN and ATTR_ARCHIVE are not supported by Unix based systems. Using them will not throw an exception, but it will have no effect on the file.
        • PALMOS - Avoid using the attribute ATTR_READ_ONLY on files located in the device's internal storage. Marking a file as read only affects also its attributes, which means it can't be undone. The only way to remove a file marked as read only is performing a hard reset.
        Parameters:
        attr - one ore more ATTR_xxx constants ORed together.
        Throws:
        IllegalArgumentIOException
        IOException
        See Also:
        ATTR_ARCHIVE, ATTR_HIDDEN, ATTR_READ_ONLY, ATTR_SYSTEM
      • getAttributes

        public final int getAttributes()
                                throws IOException
        Gets this file attributes. The file must be opened in a mode different of DONT_OPEN.

        This method does not work on desktop, but the arguments are still checked.

        Returns:
        The file attributes ORed together.
        Throws:
        IOException
        See Also:
        ATTR_ARCHIVE, ATTR_HIDDEN, ATTR_READ_ONLY, ATTR_SYSTEM
      • setTime

        public final void setTime​(byte whichTime,
                                  Time time)
                           throws IllegalArgumentIOException,
                                  IOException
        Sets the time attribute of the opened filed - cannot be used with DONT_OPEN or READ_ONLY.
        Platform specific notes:
        • JDK - This method has no effect on any file when running on JDK, it only checks if the object state and the received arguments are valid.
        • WINCE - Supports only TIME_MODIFIED if the file is stored on the device's non-volatile memory. If the file is stored in an external FAT storage, it also supports TIME_CREATED.
        • BLACKBERRY - Not supported.
        • LINUX, IPHONE and ANDROID - Unix based systems do not keep record of the file's creation time. Attempting to do so will not thrown an exception, but it will have no effect on the file.
        Parameters:
        whichTime - One or more of the TIME_xxx constants, ORed together.
        time - The new time.
        Throws:
        IllegalArgumentIOException
        IOException
        See Also:
        TIME_ALL, TIME_ACCESSED, TIME_CREATED, TIME_MODIFIED
      • getTime

        public final Time getTime​(byte whichTime)
                           throws IllegalArgumentIOException,
                                  IOException
        Retrieves the specified time attribute of the opened file - cannot be used with DONT_OPEN.
        • JDK - If the object state and the received argument are valid, it will always return the time of the last modification.
        • WINCE - Supports only TIME_MODIFIED if the file is stored on the device's non-volatile memory. If the file is stored in an external FAT storage, it also supports TIME_CREATED.
        • BLACKBERRY - Supports only TIME_MODIFIED.
        • LINUX, IPHONE and ANDROID - Unix based systems do not keep record of the file's creation time. Using the constant TIME_CREATED will return the last time the file was changed, which is updated when changes are made to the file's inode (owner, permissions, etc.), and also when the contents of the file are modified.
          The constant TIME_MODIFIED returns the last time the contents of the file were modified.
        Parameters:
        whichTime - value must be TIME_ACCESSED, TIME_CREATED or TIME_MODIFIED. Any other value will result in an exception.
        Throws:
        IllegalArgumentIOException
        IOException
        See Also:
        TIME_ACCESSED, TIME_CREATED, TIME_MODIFIED
      • getCardVolume

        public static final File getCardVolume()
                                        throws IOException
        Returns the volume File for the Windows CE and Pocket PC, and BlackBerry devices. On these devices, the volume has a special folder name, but since there's no system call that informs this, we must just test the existence of each folder, returning the first one that exists. You can set the winceVols string array to the ones you want to be searched.

        To access the card on Android devices, prefix the path with /sdcard. Be sure that the sdcard is NOT MOUNTED, otherwise your application will not have access to it. Some android devices have more than one sdcard, an internal and an external ones. On such devices, /sdcard is the internal one; to find the external path, you must get into the device because there's no API to get it. For example, on Galaxy devices, it is /mnt/extSdCard.
        Returns:
        The File object which references the volume, ended with backslash, or null if none found.
        Throws:
        IOException
        See Also:
        winceVols
      • setSize

        public final void setSize​(int newSize)
                           throws IOException
        Sets the file size, growing the size or truncating it.
        Parameters:
        newSize - The new file size.
        Throws:
        IOException
        Since:
        SuperWaba 5.83
      • getCardSerialNumber

        public static final java.lang.String getCardSerialNumber​(int slot)
                                                          throws IllegalArgumentIOException,
                                                                 IOException
        Returns the card serial number for the given slot.

        This method only works on Palm OS.

        Parameters:
        slot - The slot number, or -1 to use the last slot (which is usually an external card if the device has such slot).
        Throws:
        IllegalArgumentIOException
        IOException
        Since:
        TotalCross 1.0
      • finalize

        protected void finalize()
        Overrides:
        finalize in class java.lang.Object
      • getSlot

        public int getSlot()
        Returns the slot number passed in the constructor, or -1 if no slot was given.
        Since:
        TotalCross 1.0
      • listFiles

        public static java.lang.String[] listFiles​(java.lang.String dir)
                                            throws IOException
        Returns a recursive list of all files inside the given directory (including it). The array is sorted upon return.
        Throws:
        IOException
        Since:
        TotalCross 1.15
      • listFiles

        public static java.lang.String[] listFiles​(java.lang.String dir,
                                                   boolean recursive)
                                            throws IOException
        Lists all the files in the specified directory, and also the files in the subdirectories if recursive is true.
        Parameters:
        dir -
        recursive -
        Throws:
        IOException
      • deleteDir

        public static void deleteDir​(java.lang.String dir)
                              throws IOException
        Deletes a directory and all its subdirectories and files. If you have problems trying to recreate the directory, be sure to call Vm.gc() after calling this method.
        Throws:
        IOException
        Since:
        TotalCross 1.15
      • listRoots

        public static java.lang.String[] listRoots()
        List the root drives. If there are no roots, returns null. Works on Win32, Java, and Blackberry platforms.
        Since:
        TotalCross 1.22
      • copyTo

        public void copyTo​(File dest)
                    throws IOException
        Copies the current file to the given one. You must close both files after calling this method. Here's a sample of how to copy a file:
              File src = new File(srcFileName,File.READ_WRITE);
              File dest = new File(destFileName,File.CREATE_EMPTY);
              src.copyTo(dest);
              src.close();
              dest.close();
         
        This method is thread-safe.
        Throws:
        IOException
        Since:
        TotalCross 1.27
        See Also:
        moveTo(File)
      • moveTo

        public void moveTo​(File dest)
                    throws IOException
        Moves the current file to the given one (the original file is deleted). You must explicitly close the destination file after this operation is done. Here's a sample of how to move a file:
              File src = new File(srcFileName,File.READ_WRITE);
              File dest = new File(destFileName,File.CREATE_EMPTY);
              src.moveTo(dest);
              // src.close(); - not needed! src was deleted
              dest.close();
         
        This method is thread-safe.
        Throws:
        IOException
        Since:
        TotalCross 1.27
        See Also:
        copyTo(File)
      • copy

        public static void copy​(java.lang.String src,
                                java.lang.String dst)
                         throws IOException
        A handy method to call copyTo creating two File instances and closing them. The target file is erased if it exists. This method is thread-safe. If you want to have more control, use the copyTo method
        Throws:
        IOException
        Since:
        TotalCross 1.27
        See Also:
        copyTo(File)
      • move

        public static void move​(java.lang.String src,
                                java.lang.String dst)
                         throws IOException
        A handy method to call moveTo creating two File instances and closing them. The target file is erased if it exists. This method is thread-safe. If you want to have more control, use the other moveTo method
        Throws:
        IOException
        Since:
        TotalCross 1.27
        See Also:
        moveTo(File)
      • chmod

        public int chmod​(int mod)
                  throws IOException
        Applies the given permissions to this file. Works only on Unix-based operating systems: Linux, Android, and iOS. On JDK 1.6, the first number (user) is applied to all groups. Below you see a table with some chmod values (r = read, w = write, x = execute).
         Number   Permission
               000     ---------
               400     r--------
               444     r--r--r--
               600     rw-------
               620     rw--w----
               640     rw-r-----
               644     rw-r--r--
               645     rw-r--r-x
               646     rw-r--rw-
               650     rw-r-x---
               660     rw-rw----
               661     rw-rw---x
               662     rw-rw--w-
               663     rw-rw--wx
               664     rw-rw-r--
               666     rw-rw-r--
               700     rwx------
               750     rwxr-x---
               755     rwxr-xr-x
               777     rwxrwxrwx
         
        The numbers represents a group of 3. The first number is the permission for user, the second number for group, and the third number for others These are the possible permission values for each number:
               Permission   Binary  Decimal
                 ---         000       0
                 --x         001       1
                 -w-         010       2
                 -wx         011       3
                 r--         100       4
                 r-x         101       5
                 rw-         110       6
                 rwx         111       7    
         
        Failing to change the permission returns -1.

        Here's a sample:
              try
              {
                 // testing in a folder
                 File f = new File(Settings.appPath);
                 add(new Label("mods of appPath = "+f.chmod(-1)),CENTER,CENTER);
          
                 // testing in a file
                 String name = "test";
                 f = new File(Settings.appPath+'/'+name,File.CREATE_EMPTY);
                 int m0 = f.chmod(777); // change it
                 int m1 = f.chmod(-1); // retrieve the changed value
                 add(new Label("mods of "+name+" = "+m0+" -> "+m1+" (777)"),CENTER,AFTER+5);
              }
              catch (Exception ee)
              {
                 MessageBox.showException(ee,true);
              }
         
        Parameters:
        mod - The modifiers you want to set in DECIMAL, or -1 to just return the current ones.
        Returns:
        The modifiers that were set before you called this method (or the current modifiers, if -1 is being passed). Some platforms may return more than 3 digits, indicating extra attributes (for example, if it's a file or a directory).
        Throws:
        IOException
        Since:
        TotalCross 1.27
      • readAndClose

        @Deprecated
        public byte[] readAndClose()
                            throws IOException
        Deprecated.
        Reads the entire file into a byte array and closes itself. A handy method that can be used like this:
         byte[] bytes = new File(...,File.READ_ONLY).readAndClose();
         
        The only drawback is that this method consumes lots of memory if the file is big; use it carefully.
        Throws:
        IOException
        Since:
        TotalCross 1.53
      • readAndDelete

        @Deprecated
        public byte[] readAndDelete()
                             throws IOException
        Deprecated.
        Reads the entire file into a byte array and DELETES itself. A handy method that can be used like this:
         byte[] bytes = new File(...,File.READ_ONLY).readAndDelete();
         
        The only drawback is that this method consumes lots of memory if the file is big; use it carefully.
        Throws:
        IOException
        Since:
        TotalCross 1.53
      • writeAndClose

        @Deprecated
        public void writeAndClose​(byte[] bytes)
                           throws IOException
        Deprecated.
        Writes byte array to this file and closes itself. A handy method that can be used like this:
         new File(...,File.CREATE_EMPTY).writeAndClose(Vm.getFile("myfile.txt"));
         
        The only drawback is that this method consumes lots of memory if the file is big; use it carefully.
        Throws:
        IOException
        Since:
        TotalCross 1.53
      • read

        @Deprecated
        public byte[] read()
                    throws IOException
        Deprecated.
        Reads the file and returns a byte array with its contents.
        Throws:
        IOException
        Since:
        TotalCross 3.1
      • getAppSpecificDir

        public static File getAppSpecificDir​(java.lang.String type,
                                             java.lang.String dirName)
                                      throws IOException
        Returns a file object with a path writable by the application on the device storage.
        Parameters:
        type -
        dirName -
        Returns:
        Throws:
        IOException