Build 1.0_r1(from source)

android.os
Class FileUtils

java.lang.Object
  extended by android.os.FileUtils

public class FileUtils
extends Object

Tools for managing files. Not for public consumption.


Nested Class Summary
static class FileUtils.FileStatus
          File status information.
 
Field Summary
static int S_IRGRP
           
static int S_IROTH
           
static int S_IRUSR
           
static int S_IRWXG
           
static int S_IRWXO
           
static int S_IRWXU
           
static int S_IWGRP
           
static int S_IWOTH
           
static int S_IWUSR
           
static int S_IXGRP
           
static int S_IXOTH
           
static int S_IXUSR
           
 
Constructor Summary
FileUtils()
           
 
Method Summary
static boolean copyFile(File srcFile, File destFile)
           
static boolean copyToFile(InputStream inputStream, File destFile)
          Copy data from a source stream to destFile.
static int getFatVolumeId(String mountPoint)
          returns the FAT file system volume ID for the volume mounted at the given mount point, or -1 for failure
static boolean getFileStatus(String path, FileUtils.FileStatus status)
          Get the status for the given path.
static int getPermissions(String file, int[] outPermissions)
           
static boolean isFilenameSafe(File file)
          Check if a filename is "safe" (no metacharacters or spaces).
static String readTextFile(File file, int max, String ellipsis)
          Read a text file into a String, optionally limiting the length.
static int setPermissions(String file, int mode, int uid, int gid)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

S_IRWXU

public static final int S_IRWXU
See Also:
Constant Field Values

S_IRUSR

public static final int S_IRUSR
See Also:
Constant Field Values

S_IWUSR

public static final int S_IWUSR
See Also:
Constant Field Values

S_IXUSR

public static final int S_IXUSR
See Also:
Constant Field Values

S_IRWXG

public static final int S_IRWXG
See Also:
Constant Field Values

S_IRGRP

public static final int S_IRGRP
See Also:
Constant Field Values

S_IWGRP

public static final int S_IWGRP
See Also:
Constant Field Values

S_IXGRP

public static final int S_IXGRP
See Also:
Constant Field Values

S_IRWXO

public static final int S_IRWXO
See Also:
Constant Field Values

S_IROTH

public static final int S_IROTH
See Also:
Constant Field Values

S_IWOTH

public static final int S_IWOTH
See Also:
Constant Field Values

S_IXOTH

public static final int S_IXOTH
See Also:
Constant Field Values
Constructor Detail

FileUtils

public FileUtils()
Method Detail

getFileStatus

public static boolean getFileStatus(String path,
                                    FileUtils.FileStatus status)
Get the status for the given path. This is equivalent to the POSIX stat(2) system call.

Parameters:
path - The path of the file to be stat'd.
status - Optional argument to fill in. It will only fill in the status if the file exists.
Returns:
true if the file exists and false if it does not exist. If you do not have permission to stat the file, then this method will return false.

setPermissions

public static int setPermissions(String file,
                                 int mode,
                                 int uid,
                                 int gid)

getPermissions

public static int getPermissions(String file,
                                 int[] outPermissions)

getFatVolumeId

public static int getFatVolumeId(String mountPoint)
returns the FAT file system volume ID for the volume mounted at the given mount point, or -1 for failure

Parameters:
mount - point for FAT volume
Returns:
volume ID or -1

copyFile

public static boolean copyFile(File srcFile,
                               File destFile)

copyToFile

public static boolean copyToFile(InputStream inputStream,
                                 File destFile)
Copy data from a source stream to destFile. Return true if succeed, return false if failed.


isFilenameSafe

public static boolean isFilenameSafe(File file)
Check if a filename is "safe" (no metacharacters or spaces).

Parameters:
file - The file to check

readTextFile

public static String readTextFile(File file,
                                  int max,
                                  String ellipsis)
                           throws IOException
Read a text file into a String, optionally limiting the length.

Parameters:
file - to read (will not seek, so things like /proc files are OK)
max - length (positive for head, negative of tail, 0 for no limit)
ellipsis - to add of the file was truncated (can be null)
Returns:
the contents of the file, possibly truncated
Throws:
IOException - if something goes wrong reading the file

Build 1.0_r1(from source)

Please submit a feedback, bug or feature