Java Path File Read nio getReaderForFile(final Path file)

Here you can find the source of getReaderForFile(final Path file)

Description

get Reader For File

License

Open Source License

Declaration

private static BufferedReader getReaderForFile(final Path file)
            throws FileNotFoundException, IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

import java.nio.file.Files;
import java.nio.file.Path;

import java.util.zip.GZIPInputStream;

public class Main {
    private static BufferedReader getReaderForFile(final Path file)
            throws FileNotFoundException, IOException {
        final String filename = file.getFileName().toString().toLowerCase();
        if (filename.endsWith(".gz")) {
            return new BufferedReader(new InputStreamReader(
                    new GZIPInputStream(Files.newInputStream(file))));
        }//from  w  ww .j  a  v a 2 s.c om
        return Files.newBufferedReader(file);
    }
}

Related

  1. breadcrumbPath(String urlPrefix, String path, char sep)
  2. checkReadableDirectory(final Path directory)
  3. getResourceAsStream(String resourcePath, ClassLoader classLoader, Class clazz, String resourceDesc, Consumer logger)
  4. getTestClassPathURLClassLoader(ClassLoader parent)
  5. load(Path p, PrintStream errorStream, String propertyInfo)
  6. loadFile(final Path filePath)