Load file data using class loader in java


public class PublicServicesSkeleton{
    	static final ClassLoader loader = PublicServicesSkeleton.class.getClassLoader();
    	private static List<String> cuidList;
    	static {
    		try {
		InputStream inputStream = loader.getResourceAsStream("USER_GASSI_KO.txt");
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
				
		cuidList = new ArrayList<String>();
		String strLine;
				
		// Read file line by line
		while ((strLine = bufferedReader.readLine())!=null) {
			cuidList.add(strLine);
		}		
		bufferedReader.close();
		inputStream.close();
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
    }
}

This entry was posted in JAVA on by .
Rahul Thakur

About Rahul Thakur

Hi, this is Rahul working as Software Engineer at Orange Business Services. Responsible for Requirement analysis, design ,development, deployment, and testing. Working on Agile methodology and Scrum Experience on UML, OOAD, OOPS, Design patterns, Java / J2ee technologies, ORM, performance and load tests, code review and lot of SDLC activities.