File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes how to read config file from other mahine using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to read config file from other mahine using java" Watch "how to read config file from other mahine using java" New topic
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: 18671
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to read config file from other mahine using java