Java File to String fileToStream(final File file)

Here you can find the source of fileToStream(final File file)

Description

Reads a file and returns it as a stream.

License

Apache License

Declaration

public static InputStream fileToStream(final File file) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.BufferedInputStream;

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

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

public class Main {
    /**//from  ww  w  .j  av  a  2 s .c  o m
     * Reads a file and returns it as a stream.
     */
    public static InputStream fileToStream(final File file) {
        try {
            return new BufferedInputStream(new FileInputStream(file));
        } catch (final IOException ioEx) {
            // Wrap it
            throw new RuntimeException(ioEx);
        }
    }
}

Related

  1. fileToStr(String strInput)
  2. fileToStream(File source, OutputStream target)
  3. fileToStream(String filename)
  4. fileToString(File f)
  5. fileToString(File f)
  6. fileToString(File f)