Class CharSources


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.google.common.io.CharSource ofContent​(byte[] content)
      Obtains an instance of CharSource from a text variable, specified as a byte array.
      static com.google.common.io.CharSource ofContent​(byte[] content, java.nio.charset.Charset charset)
      Obtains an instance of CharSource from a text variable, specified as a byte array.
      static com.google.common.io.CharSource ofContent​(java.lang.String content)
      Obtains an instance of CharSource from a text variable, specified as a String object.
      static com.google.common.io.CharSource ofFile​(java.io.File file)
      Obtains an instance of CharSource from a file object, specified as a File.
      static com.google.common.io.CharSource ofFile​(java.io.File file, java.nio.charset.Charset charset)
      Obtains an instance of CharSource from a file object, specified as a File.
      static com.google.common.io.CharSource ofFileName​(java.lang.String fileName)
      Obtains an instance of CharSource from a file name, specified as a String.
      static com.google.common.io.CharSource ofFileName​(java.lang.String fileName, java.nio.charset.Charset charset)
      Obtains an instance of CharSource from a file name, specified as a String.
      static com.google.common.io.CharSource ofPath​(java.nio.file.Path path)
      Obtains an instance of CharSource from a file path, specified as a Path.
      static com.google.common.io.CharSource ofPath​(java.nio.file.Path path, java.nio.charset.Charset charset)
      Obtains an instance of CharSource from a file path, specified as a Path.
      static com.google.common.io.CharSource ofUrl​(java.net.URL url)
      Obtains an instance of CharSource from a URL, specified as a URL object.
      static com.google.common.io.CharSource ofUrl​(java.net.URL url, java.nio.charset.Charset charset)
      Obtains an instance of CharSource from an URL, specified as a URL object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • ofFileName

        public static com.google.common.io.CharSource ofFileName​(java.lang.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 com.google.common.io.CharSource ofFileName​(java.lang.String fileName,
                                                                 java.nio.charset.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 com.google.common.io.CharSource ofFile​(java.io.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 com.google.common.io.CharSource ofFile​(java.io.File file,
                                                             java.nio.charset.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 com.google.common.io.CharSource ofPath​(java.nio.file.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 com.google.common.io.CharSource ofPath​(java.nio.file.Path path,
                                                             java.nio.charset.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 com.google.common.io.CharSource ofUrl​(java.net.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 com.google.common.io.CharSource ofUrl​(java.net.URL url,
                                                            java.nio.charset.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 com.google.common.io.CharSource ofContent​(java.lang.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 com.google.common.io.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 com.google.common.io.CharSource ofContent​(byte[] content,
                                                                java.nio.charset.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