File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Accesing an unshared folder using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Accesing an unshared folder using java" Watch "Accesing an unshared folder using java" New topic

Accesing an unshared folder using java

kranthi chamarthi
Ranch Hand

Joined: May 08, 2007
Posts: 95
In our application,there are three servers
1)Application Server
2)File server
3)Database server
The files that are uploaded by user will be uploaded on to the file server and the uploaded content(video files) should be served by the application server.Now the problem is, if the application server is restarted(due to some reason) then it is not able to access the content on file server until manually the folder is accessed from the application server(by giving the ipaddress/c$ and giving the credentials).From then on, the application server will be able to access the file server.Now i want to do this programatically(checking if the file server folder is accessible from the application server before uploading ,and if the folder is not accessible then supplying the login credentials).Can some one suggest me the solution.
Thanks in advance.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 692
If you have a commandline you want to execute from a java program you could use the Runtime class's exec() method. There are many posts with examples of how to do this. For example:

Runtime.getRuntime().exec(" /c dir T*.java > TestDOSCMD.txt");

If you need to see the results, use the Process class with the above:

Process proc = Runtime.getRuntime().exec(" /c CD E:");
BufferedReader br = new BufferedReader(
new InputStreamReader(proc.getInputStream()));
I agree. Here's the link:
subject: Accesing an unshared folder using java
It's not a secret anymore!