package com.java.discussions101;import java.io.File;import java.io.FileNotFoundException;import java.io.IOException;import java.util.Properties;public class Main { public static void main(String[] args) throws FileNotFoundException, IOException { Properties prop = new Properties(); //prop.load(ClassLoader.getSystemResourceAsStream("property/file.txt")); prop.load(Main.class.getResourceAsStream("/property/file.txt")); String str=prop.getProperty(""); System.out.println(str); }}You can choose 2 ways to load files and read it in your code. You can choose either the ClassLoader or the Class.clazz to load file. In my case I have a director in my root named "property" and inside it a file named "file.txt" is there.Cheers....
package com.java.discussions101;/** * @author Supratim Samanta * @since 13/01/2011 2025HRS * @modified 14/01/2011 2348HRS * */import java.io.File;import java.io.IOException;import java.util.ArrayList;import java.util.Iterator;import java.util.List;public class FileTree { private static List fileArray = new ArrayList(); private static int count = 0; private static final String location = "./"; public static void main(String[] args) throws IOException { File file = new File(location); getFileTreeIterated(file); printAll(fileArray); } private static void getFileTreeIterated(File file) { if (file.isDirectory()) { File[] fileList = file.listFiles(); try { for (File tempFile : fileList) { if (tempFile.isDirectory()) { getFileTreeIterated(tempFile); } else { fileArray.add(tempFile); count++; } } } catch (NullPointerException npe) { return; } } else { fileArray.add(file); count++; } } private static void printAll(List array) throws IOException { if (!(array.size() == 0)) { Iterator it = array.iterator(); System.out.println("The Number Of Files : " + array.size()); while (it.hasNext()) { File tempFile = it.next(); System.out.println(tempFile.getCanonicalPath()); } } else System.out.println("NOTHING FOUND"); }}Just change the "location" String attribute to your directory path. All files in that directory wiil be displayed. In my case the location is the current directory.Cheers....