Object FileHelper

  • All Implemented Interfaces:

    
    public class FileHelper
    
                        

    A helper object for file operations.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static FileHelper INSTANCE
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • getDir

         final File getDir()

        Returns the directory of NaverAdsServices

      • getFile

         final File getFile(String fileName)

        Returns the file. if does not exist or is not a file, null is returned.

        Parameters:
        fileName - the fileName
        Returns:

        the file that associates fileName.

      • writeFile

         final Boolean writeFile(String fileName, String content)

        Writes a String to a file.

        Parameters:
        fileName - the fileName to write.
        content - the content to write.
        Returns:

        true if the file is successfully wrote, false otherwise.

      • readFileAsJSONObject

         final JSONObject readFileAsJSONObject(String fileName)

        Reads the content of a File into a JSONObject. If the file does not exist or is not a file, null is returned.

        Parameters:
        fileName - the fileName to read.
        Returns:

        a JSONObject containing all the content of the file, or null if it doesn't exists.

      • deleteFile

         final Boolean deleteFile(String fileName)

        Deletes a file.

        Parameters:
        fileName - the fileName to delete.
        Returns:

        true if the file is successfully deleted, false otherwise.

      • readText

         final String readText(String fileName)

        Reads the content of a File into a String. If the file does not exist or is not a file, null is returned.

        Parameters:
        fileName - the fileName to read.
        Returns:

        a String containing all the content of the file, or null if it doesn't exists.

      • readText

         final String readText(File file)

        Reads the content of a File into a String. If the file does not exist or is not a file, null is returned.

        Parameters:
        file - the file to read.
        Returns:

        a String containing all the content of the file, or null if it doesn't exists.