Class CharSources


  • public final class CharSources
    extends Object
    Helper that allows CharSource objects to be created.
    • Method Detail

      • ofFileName

        public static CharSource ofFileName​(String fileName)
        Obtains an instance of CharSource from a file name, specified as a String.
        Parameters:
        fileName - the file name, as a String
        Returns:
        a new instance of CharSource with UTF-8 for charset.
      • ofFileName

        public static CharSource ofFileName​(String fileName,
                                            Charset charset)
        Obtains an instance of CharSource from a file name, specified as a String. This also takes in a specific character set, as a Charset.
        Parameters:
        fileName - the file name, as a String
        charset - the charset to build the new CharSource based on
        Returns:
        a new instance of CharSource
      • ofFile

        public static CharSource ofFile​(File file)
        Obtains an instance of CharSource from a file object, specified as a File.
        Parameters:
        file - the file object
        Returns:
        a new instance of CharSource with UTF-8 for charset.
      • ofFile

        public static CharSource ofFile​(File file,
                                        Charset charset)
        Obtains an instance of CharSource from a file object, specified as a File. This also takes in a specific character set, as a Charset.
        Parameters:
        file - the file object
        charset - the charset to build the new CharSource based on
        Returns:
        a new instance of CharSource
      • ofPath

        public static CharSource ofPath​(Path path)
        Obtains an instance of CharSource from a file path, specified as a Path.
        Parameters:
        path - the path to create a CharSource from
        Returns:
        a new instance of CharSource with UTF-8 for charset.
      • ofPath

        public static CharSource ofPath​(Path path,
                                        Charset charset)
        Obtains an instance of CharSource from a file path, specified as a Path. This also takes in a specific character set, as a Charset.
        Parameters:
        path - the path to create a CharSource from
        charset - the charset to build the new CharSource based on
        Returns:
        a new instance of CharSource
      • ofUrl

        public static CharSource ofUrl​(URL url)
        Obtains an instance of CharSource from a URL, specified as a URL object.
        Parameters:
        url - the url to create a CharSource from
        Returns:
        a new instance of CharSource with UTF-8 for charset.
      • ofUrl

        public static CharSource ofUrl​(URL url,
                                       Charset charset)
        Obtains an instance of CharSource from an URL, specified as a URL object. This also takes in a specific character set, as a Charset.
        Parameters:
        url - the url to create a CharSource from
        charset - the charset to build the new CharSource based on
        Returns:
        a new instance of CharSource.
      • ofContent

        public static CharSource ofContent​(String content)
        Obtains an instance of CharSource from a text variable, specified as a String object.
        Parameters:
        content - the text to create a CharSource for
        Returns:
        a new instance of CharSource with UTF-8 for charset
      • ofContent

        public static CharSource ofContent​(byte[] content)
        Obtains an instance of CharSource from a text variable, specified as a byte array.
        Parameters:
        content - the text to create a CharSource for
        Returns:
        a new instance of CharSource with UTF-8 for charset
      • ofContent

        public static CharSource ofContent​(byte[] content,
                                           Charset charset)
        Obtains an instance of CharSource from a text variable, specified as a byte array. This also takes in a specific character set, as a Charset.
        Parameters:
        content - the text to create a CharSource for
        charset - the charset to build the new CharSource based on
        Returns:
        a new instance of CharSource