Here you can find the source of loadReaderFromClasspath(Class c, String filename)
Parameter | Description |
---|---|
filename | a parameter |
public static BufferedReader loadReaderFromClasspath(Class c, String filename)
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.InputStreamReader; public class Main { /**//from ww w. j a va2s. c om * "Transform" a file on the classpath into a BufferedReader * * @param filename * @return */ public static BufferedReader loadReaderFromClasspath(Class c, String filename) { return new BufferedReader(new InputStreamReader(c.getClassLoader().getResourceAsStream(filename))); } /** * "Transform" a file on the classpath into a BufferedReader * * @param filename * @return */ public static BufferedReader loadReaderFromClasspath(String filename) { try { return new BufferedReader(new FileReader(new File(filename))); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }