## com.blogspot.applications4android.comicreader.core
Class FileUtils

    java.lang.Object
      com.blogspot.applications4android.comicreader.core.FileUtils

    public class FileUtils

extends java.lang.Object

Class containing helper methods for working on files

Field Summary
`static int` `BUFF_SIZE` buffer size (in bytes) for BufferedReader's
`static java.lang.String` `COMIC_ROOT` root folder for storing info
`static int` `MIN_BYTES_SDCARD_MB` minimum sd-card free space required for this app (in MB)
`static int` `SB_CAPACITY` string builder size (in bytes)

Method Summary
`static void` `checkFreeSpaceSdcard()` Checks whether there's enough space on the sd-card
`static boolean` `copyFile(java.io.File src, java.io.File dst)` Copy source file to destination
`static boolean` `delete(java.io.File file)` Delete a file/folder if it exists
`static java.io.File` `getComicRoot()` Gets the root comic folder
`static java.io.File` `getSdcard()` Returns the path to the sdcard
`static java.lang.String` `getTempFile()` Get a temporary filename using Time + Random.
`static java.lang.String` `getTempFile(java.lang.String prefix, java.lang.String suffix)` Get a temporary filename using Time + Random.
`static boolean` `mkdir(java.io.File folder)` Create a folder if it doesn't exist already.
`static int` `numLines(java.io.File file)` Calculate the number of lines in the plain text file.
`static int` `numLines(java.io.Reader in)` Calculate the number of lines in the plain text file
`static void` `recursiveDelete(java.io.File dir)` Recursively delete a directory (equivalent to 'rm -rf')
`static long` `sdcardAvailableBytesMB()` Gets the available number of bytes in your sdcard (in MB)
`static java.lang.String` `slurp(java.io.InputStream is)` Read the whole file into a string.
`static java.lang.String` `slurp(java.lang.String file, AssetManager am)` Slurp a file (which is present in the android_asset) into a string
`static void` `storeString(java.lang.String s, java.io.File f)` Store a string to the file
`static boolean` `touch(java.lang.String file)` Creates an empty file

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### BUFF_SIZE

    public static final int BUFF_SIZE

  buffer size (in bytes) for BufferedReader's

  See Also:
    Constant Field Values

### SB_CAPACITY

    public static final int SB_CAPACITY

  string builder size (in bytes)

  See Also:
    Constant Field Values

### MIN_BYTES_SDCARD_MB

    public static final int MIN_BYTES_SDCARD_MB

  minimum sd-card free space required for this app (in MB)

  See Also:
    Constant Field Values

### COMIC_ROOT

    public static final java.lang.String COMIC_ROOT

  root folder for storing info

  See Also:
    Constant Field Values

Method Detail

### recursiveDelete

    public static void recursiveDelete(java.io.File dir)

  Recursively delete a directory (equivalent to 'rm -rf')

  Parameters:
    `dir` - directory to be deleted

### touch

    public static boolean touch(java.lang.String file)

  Creates an empty file

  Parameters:
    `file` - file to be created
  Returns:
    true if the file is created, else false

### numLines

    public static int numLines(java.io.Reader in)

  Calculate the number of lines in the plain text file

  Parameters:
    `in` - reader
  Returns:
    num-lines

### numLines

    public static int numLines(java.io.File file)

  Calculate the number of lines in the plain text file.

  Parameters:
    `file` - the file of interest
  Returns:
    number of lines in the file

### slurp

    public static java.lang.String slurp(java.io.InputStream is)
                                  throws java.io.IOException

  Read the whole file into a string. This will close the stream after reading!

  Parameters:
    `is` - file pointer
  Returns:
    string
  Throws:
    `java.io.IOException`

### slurp

    public static java.lang.String slurp(java.lang.String file,
                                         AssetManager am)
                                  throws java.io.IOException

  Slurp a file (which is present in the android_asset) into a string

  Parameters:
    `file` - the file of interest
    `am` - the asset manager which will be used to find the input file
  Returns:
    its contents as a string
  Throws:
    `java.io.IOException`

### storeString

    public static void storeString(java.lang.String s,
                                   java.io.File f)
                            throws java.io.IOException,
                                   ComicSDCardFull

  Store a string to the file

  Parameters:
    `s` - string
    `f` - file
  Throws:
    `java.io.IOException`
    `ComicSDCardFull`

### delete

    public static boolean delete(java.io.File file)

  Delete a file/folder if it exists

  Parameters:
    `file` - the file to be deleted.
  Returns:
    true if deletion was successful. Else false.

### mkdir

    public static boolean mkdir(java.io.File folder)

  Create a folder if it doesn't exist already.

  Parameters:
    `folder` - the folder to be created if it doesn't exist.
  Returns:
    true if the folder was created successfully

### getTempFile

    public static java.lang.String getTempFile(java.lang.String prefix,
                                               java.lang.String suffix)

  Get a temporary filename using Time + Random.

  Parameters:
    `prefix` - the prefix to be used for this temp file.
    `suffix` - the suffix to be used for this temp file.
  Returns:
    the name of the temp file.

### getTempFile

    public static java.lang.String getTempFile()

  Get a temporary filename using Time + Random. The prefix and suffix for this temp file will be "" and ".temp" respectively.

  Returns:
    the name of the temp file.

### checkFreeSpaceSdcard

    public static void checkFreeSpaceSdcard()
                                     throws ComicSDCardFull

  Checks whether there's enough space on the sd-card

  Throws:
    `ComicSDCardFull`

### sdcardAvailableBytesMB

    public static long sdcardAvailableBytesMB()

  Gets the available number of bytes in your sdcard (in MB)

  Returns:
    available number of bytes (returns 0 if sdcard is unavailable)

### getSdcard

    public static java.io.File getSdcard()

  Returns the path to the sdcard

  Returns:
    path. Returns null if sdcard is not mounted

### getComicRoot

    public static java.io.File getComicRoot()

  Gets the root comic folder

  Returns:
    folder

### copyFile

    public static boolean copyFile(java.io.File src,
                                   java.io.File dst)

  Copy source file to destination

  Parameters:
    `src` - source location
    `dst` - destination location
  Returns:
    true on success