Java InputStream Create getInputStream(final String fileName)

Here you can find the source of getInputStream(final String fileName)

Description

Get input stream for specified file name.

License

BSD License

Parameter

Parameter Description
fileName Relative file name (not full path)

Return

An input stream

Declaration

public static InputStream getInputStream(final String fileName) 

Method Source Code

//package com.java2s;
/*L//from   ww  w . j  a v a 2 s.c o  m
 *  Copyright RTI International
 *
 *  Distributed under the OSI-approved BSD 3-Clause License.
 *  See http://ncip.github.com/webgenome/LICENSE.txt for details.
 */

import java.io.InputStream;

public class Main {
    /**
     * Get input stream for specified file name.
     * @param fileName Relative file name (not full path)
     * @return An input stream
     */
    public static InputStream getInputStream(final String fileName) {
        Thread curThread = Thread.currentThread();
        ClassLoader loader = curThread.getContextClassLoader();
        return loader.getResourceAsStream(fileName);
    }
}

Related

  1. getInputStream(FileInputStream fileInput)
  2. getInputStream(final File file)
  3. getInputStream(final File file)
  4. getInputStream(final File file, final boolean createFile)
  5. getInputStream(final Serializable obj)
  6. getInputStream(final String sourceFolder, final Class clazz)
  7. getInputStream(String content)
  8. getInputStream(String data)
  9. getInputStream(String fileName)