Java Resource Load getResourceAsBufferedReader(Class clazz, String resourceName)

Here you can find the source of getResourceAsBufferedReader(Class clazz, String resourceName)

Description

get Resource As Buffered Reader

License

Open Source License

Declaration

public static BufferedReader getResourceAsBufferedReader(Class<?> clazz, String resourceName) 

Method Source Code


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

import java.io.BufferedReader;
import java.io.File;

import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static BufferedReader getResourceAsBufferedReader(Class<?> clazz, String resourceName) {
        return new BufferedReader(getResourceAsInputStreamReader(clazz, resourceName));
    }//from w w  w .  j  a va2  s.com

    public static InputStreamReader getResourceAsInputStreamReader(Class<?> clazz, String resourceName) {
        return new InputStreamReader(getResourceAsStream(clazz, resourceName));
    }

    public static InputStream getResourceAsStream(Class<?> clazz, String resourceName) {
        return clazz.getResourceAsStream(resourceName);
    }

    public static InputStream getResourceAsStream(Class<?> clazz, File file) {
        return getResourceAsStream(clazz, toResourceName(file));
    }

    public static String toResourceName(File file) {
        return toResourceName(file.getPath());
    }

    public static String toResourceName(String name) {
        return name.replaceAll("\\\\", "/");
    }
}

Related

  1. getResource(String name)
  2. getResource(String path)
  3. getResource(String propertiesPath)
  4. getResource(String uri)
  5. getResourceAbsolutePath(String pluginId, String... path)
  6. getResourceAsByteArray(Object context, String resourceName)
  7. getResourceAsByteArray(String url)
  8. getResourceAsBytes(Class cl, String resname)
  9. getResourceAsBytes(Class testClass, String resourceName)