| Author |
how to read config file from other mahine using java
|
james edwin
Ranch Hand
Joined: Nov 22, 2001
Posts: 393
|
|
HI, I am reading config file form my harddisk and follwing is the code. Code starts from here :- import java.io.*; import java.util.*; public class ReadProperties { public Properties getProperties() { String FileName = "TestProperty.properties"; System.out.println("File name "+FileName); InputStream is = getClass().getResourceAsStream(FileName); Properties dbProps = new Properties(); try { dbProps.load(is); } catch (Exception e) { System.out.println("Can't read the properties file. " +e.getMessage()); dbProps =null; } return dbProps; } public static void main(String[] args) { ReadProperties readProperties = new ReadProperties(); Properties dbProp = readProperties.getProperties(); String userName = dbProp.getProperty("userName"); System.out.println("User name "+userName); } } Code ends here . Above code works fine. Now the problem is this config file is lying on the other server.What should i do..?? Can anyone throw some light ...on this (pls i don't want to use RMI or JNDI in this)
|
Regards,
James
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
|
The simplest method is probably to create a URL object with the URL of the remote file. Then use openConnection() to get an InputStream, and process it just as you did before. Otherwise you'll need to create a Socket, I imagine - but the URL is probably simpler. I suggest posting to Sockets and Internet Protocols if you have troubles.
|
"I'm not back." - Bill Harding, Twister
|
 |
james edwin
Ranch Hand
Joined: Nov 22, 2001
Posts: 393
|
|
Hi jim, I think ya that can be possible, thanks for the reply.
|
 |
 |
|
|
subject: how to read config file from other mahine using java
|
|
|