Hi Question in java rearding files

mickygreen

New member
Hi Question in java rearding files

Hi folks, I guess that maybe you can help me with something. Currently my program is reading a property file and I am using: ... File configFile=new File(CONFIG_FILE); ... CONFIG_FILE= ".\file.properties" The problem is that the file must be in the same place I run my main. The program I wrote is working for different clients and I don't want them to put the file exactly where the jar/main class are. I would like that the file name and plac will be defined in the classpath and the jvm will know to seek for it there. Does anyone know if it possible or can be done? Any more suggestion will be happily taken care of. Thanks, Micky.
 

justme5

New member
אין בעיה

אתה יכול להגדיר את הספרייה הנחשקת ב classpath או כ D- ל jvm.
 

mickygreen

New member
Thanks. I did it this nice way

InputStream is = ClientAdaptor.class.getClassLoader().getResourceAsStream("file.txt"); Properties prop = new Properties(); prop.load(is); PropertyConfigurator.configure(prop); And now I just added the path to the classpath. The -D is less oriented to my clients, so in the manual I send to them I prefer they will define the classpath. Thanks, anyway.
 
למעלה