Class ReaderFactory


  • public final class ReaderFactory
    extends java.lang.Object
    Create a reader from a file with correct encoding
    • Constructor Detail

      • ReaderFactory

        private ReaderFactory()
    • Method Detail

      • createBufferedReader

        public static java.io.BufferedReader createBufferedReader​(java.io.File file,
                                                                  java.nio.charset.Charset defaultCharset)
                                                           throws java.io.IOException
        Create a reader from a file with correct encoding
        Parameters:
        file - The file to read from
        defaultCharset - defaultCharset to use if can't be determined
        Returns:
        BufferedReader for the file with the correct encoding
        Throws:
        java.io.IOException - if some I/O error ocurrs
      • createBufferedReader

        public static java.io.BufferedReader createBufferedReader​(java.io.File file)
                                                           throws java.io.IOException
        Create a reader from a file with correct encoding. If charset cannot be determined, it uses the system default charset.
        Parameters:
        file - The file to read from
        Returns:
        BufferedReader for the file with the correct encoding
        Throws:
        java.io.IOException - if some I/O error ocurrs
      • createReaderFromFile

        @Deprecated
        public static java.io.Reader createReaderFromFile​(java.io.File file,
                                                          java.nio.charset.Charset defaultCharset)
                                                   throws java.io.IOException
        Create a reader from a file with the correct encoding
        Parameters:
        file - The file to read from
        defaultCharset - defaultCharset to use if can't be determined
        Returns:
        Reader for the file with the correct encoding
        Throws:
        java.io.IOException - if some I/O error ocurrs
      • createReaderFromFile

        @Deprecated
        public static java.io.Reader createReaderFromFile​(java.io.File file)
                                                   throws java.io.IOException
        Create a reader from a file with the correct encoding. If charset cannot be determined, it uses the system default charset.
        Parameters:
        file - The file to read from
        Returns:
        Reader for the file with the correct encoding
        Throws:
        java.io.IOException - if some I/O error ocurrs