This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 685
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
Similar Threads
Accessing File on UNIX
Accesing Files stored on remote server by using Credentials
Include HTML as static resource
How to bind images and text together in same jsp page in easiest way?
opening .xls file using jsp