Java InputStream Create getInputStream(File f)

Here you can find the source of getInputStream(File f)

Description

Gets the input stream for a given file (for tar archives)

License

Open Source License

Parameter

Parameter Description
f File

Exception

Parameter Description
FileNotFoundException When the file's not found

Return

InputStream

Declaration

private static InputStream getInputStream(File f) throws FileNotFoundException 

Method Source Code

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.io.IOException;
import java.io.InputStream;

import java.util.zip.GZIPInputStream;

public class Main {
    /**//  w  w  w .  ja v  a2 s  .c om
     * Gets the input stream for a given file (for tar archives)
     *
     * @param f
     *       File
     *
     * @return InputStream
     *
     * @throws FileNotFoundException
     *       When the file's not found
     */
    private static InputStream getInputStream(File f) throws FileNotFoundException {
        InputStream is = new FileInputStream(f);
        try {
            return new GZIPInputStream(is);
        } catch (IOException e) {
            return new FileInputStream(f);
        }
    }
}

Related

  1. asInputStream(byte[] bytes)
  2. asInputStream(File file)
  3. asInputStream(Object content)
  4. asInputStream(String str)
  5. getInputStream(File jarFile, String fileName)
  6. getInputStream(File tarFile)
  7. getInputStream(File tarFile)
  8. getInputStream(File TheFile)