|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.android.utils.FileUtils
public final class FileUtils
| Field Summary | |
|---|---|
static com.google.common.base.Function<java.io.File,java.lang.String> |
GET_NAME
|
static com.google.common.base.Function<java.io.File,java.lang.String> |
GET_PATH
|
| Method Summary | |
|---|---|
static void |
copy(java.io.File from,
java.io.File toDir)
|
static void |
createFile(java.io.File file,
java.lang.String content)
|
static void |
delete(java.io.File file)
|
static void |
deleteFolder(java.io.File folder)
|
static void |
deleteIfExists(java.io.File file)
|
static void |
emptyFolder(java.io.File folder)
|
static java.util.List<java.io.File> |
find(java.io.File base,
java.util.regex.Pattern pattern)
Find a list of files in a directory, using a specified path pattern. |
static com.google.common.base.Optional<java.io.File> |
find(java.io.File base,
java.lang.String name)
Find a file with the specified name in a given directory . |
static com.google.common.collect.FluentIterable<java.io.File> |
getAllFiles(java.io.File dir)
|
static java.lang.String |
getDirectoryNameForJar(java.io.File inputFile)
Chooses a directory name, based on a JAR file name, considering exploded-aar and classes.jar. |
static java.lang.String |
getNamesAsCommaSeparatedList(java.lang.Iterable<java.io.File> files)
|
static java.io.File |
join(java.io.File dir,
java.lang.Iterable<java.lang.String> paths)
Joins a list of path segments to a given File object. |
static java.io.File |
join(java.io.File dir,
java.lang.String... paths)
Joins a list of path segments to a given File object. |
static java.lang.String |
join(java.lang.Iterable<java.lang.String> paths)
Joins a set of segment into a string, separating each segments with a host-specific path separator. |
static java.lang.String |
join(java.lang.String... paths)
Joins a set of segment into a string, separating each segments with a host-specific path separator. |
static java.lang.String |
loadFileWithUnixLineSeparators(java.io.File file)
Loads a text file forcing the line separator to be of Unix style '\n' rather than being Windows style '\r\n'. |
static void |
mkdirs(java.io.File folder)
|
static byte[] |
readSegment(java.io.File file,
long start,
int length)
Reads a portion of a file to memory. |
static java.lang.String |
relativePath(java.io.File file,
java.io.File dir)
Computes the relative of a file or directory with respect to a directory. |
static java.lang.String |
relativePossiblyNonExistingPath(java.io.File file,
java.io.File dir)
Computes the relative of a file or directory with respect to a directory. |
static void |
renameTo(java.io.File file,
java.io.File to)
|
static java.lang.String |
sha1(java.io.File file)
|
static java.lang.String |
toSystemDependentPath(java.lang.String path)
Converts a /-based path into a path using the system dependent separator. |
static java.lang.String |
toSystemIndependentPath(java.lang.String path)
Converts a system-dependent path into a /-based path. |
static com.google.common.base.Predicate<java.io.File> |
withExtension(java.lang.String extension)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final com.google.common.base.Function<java.io.File,java.lang.String> GET_NAME
public static final com.google.common.base.Function<java.io.File,java.lang.String> GET_PATH
| Method Detail |
|---|
@NonNull
public static com.google.common.base.Predicate<java.io.File> withExtension(@NonNull
java.lang.String extension)
public static void deleteFolder(@NonNull
java.io.File folder)
throws java.io.IOException
java.io.IOException
public static void emptyFolder(@NonNull
java.io.File folder)
throws java.io.IOException
java.io.IOException
public static void copy(@NonNull
java.io.File from,
@NonNull
java.io.File toDir)
throws java.io.IOException
java.io.IOException
public static void mkdirs(@NonNull
java.io.File folder)
public static void delete(@NonNull
java.io.File file)
throws java.io.IOException
java.io.IOException
public static void deleteIfExists(@NonNull
java.io.File file)
throws java.io.IOException
java.io.IOException
public static void renameTo(@NonNull
java.io.File file,
@NonNull
java.io.File to)
throws java.io.IOException
java.io.IOException
@NonNull
public static java.io.File join(@NonNull
java.io.File dir,
@NonNull
java.lang.String... paths)
dir - the file object.paths - the segments.
@NonNull
public static java.io.File join(@NonNull
java.io.File dir,
@NonNull
java.lang.Iterable<java.lang.String> paths)
dir - the file object.paths - the segments.
@NonNull
public static java.lang.String join(@NonNull
java.lang.String... paths)
paths - the segments.
@NonNull
public static java.lang.String join(@NonNull
java.lang.Iterable<java.lang.String> paths)
paths - the segments.
@NonNull
public static java.lang.String loadFileWithUnixLineSeparators(@NonNull
java.io.File file)
throws java.io.IOException
java.io.IOException
@NonNull
public static java.lang.String relativePath(@NonNull
java.io.File file,
@NonNull
java.io.File dir)
file - the file or directory, which must exist in the filesystemdir - the directory to compute the path relative to
dir to file; if file is a directory
the path comes appended with the file separator (see documentation on relativize
on java's URI class)
@NonNull
public static java.lang.String relativePossiblyNonExistingPath(@NonNull
java.io.File file,
@NonNull
java.io.File dir)
/a/b/c and the directory
is /a, this method returns b/c.
file - the path that may not correspond to any existing path in the filesystemdir - the directory to compute the path relative to
dir to file; if file is a directory
the path comes appended with the file separator (see documentation on relativize
on java's URI class)
@NonNull
public static java.lang.String toSystemDependentPath(@NonNull
java.lang.String path)
path - the system independent path to convert
@NonNull
public static java.lang.String toSystemIndependentPath(@NonNull
java.lang.String path)
path - the system dependent path
@NonNull
public static java.lang.String sha1(@NonNull
java.io.File file)
throws java.io.IOException
java.io.IOException
@NonNull
public static com.google.common.collect.FluentIterable<java.io.File> getAllFiles(@NonNull
java.io.File dir)
@NonNull
public static java.lang.String getNamesAsCommaSeparatedList(@NonNull
java.lang.Iterable<java.io.File> files)
@NonNull
public static java.lang.String getDirectoryNameForJar(@NonNull
java.io.File inputFile)
public static void createFile(@NonNull
java.io.File file,
@NonNull
java.lang.String content)
throws java.io.IOException
java.io.IOException
public static java.util.List<java.io.File> find(@NonNull
java.io.File base,
@NonNull
java.util.regex.Pattern pattern)
public static com.google.common.base.Optional<java.io.File> find(@NonNull
java.io.File base,
@NonNull
java.lang.String name)
@NonNull
public static byte[] readSegment(@NonNull
java.io.File file,
long start,
int length)
throws java.lang.Exception
file - the file to read data fromstart - the offset in the file to start readinglength - the number of bytes to read
java.lang.Exception - failed to read the file
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||