File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes Check the file/found or not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Check the file/found or not" Watch "Check the file/found or not" New topic
Author

Check the file/found or not

Rodricks george
Ranch Hand

Joined: Sep 10, 2006
Posts: 97
Dear Sir,

I have a file in c:\window\test.dll.... i want to create a program so that i should check the file present in that directory or not......

Please give some idea....

-Rodricks
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308


Rahul Bhattacharjee
LinkedIn - Blog
Rodricks george
Ranch Hand

Joined: Sep 10, 2006
Posts: 97
Thank you so much sir.....
Rodricks george
Ranch Hand

Joined: Sep 10, 2006
Posts: 97
Dear Sir,
The File Checking program i have written in action class.... if i deploy it in weblogic in Linux server and if i get access to that action class it is checking That machine OS information but i am opening the application in Windows PC..... it is not checking in my PC.... What to do to get my PC information... pls solve that

-Rodricks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
it is not checking in my PC

What does that mean? Are you running the code Rahul posted and it is not giving the correct result?


Ping & DNS - updated with new look and Ping home screen widget
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Sorry Rodricks george , could not get much from you post. ;-)
Rodricks george
Ranch Hand

Joined: Sep 10, 2006
Posts: 97
Dear Sir,

This is my code


String osname=System.getProperty("os.name");
System.out.println(osname);
String userHome=System.getProperty("user.home");
System.out.println("User Home Direcory:->"+userHome);




boolean exists = (new File("C:/WINDOWS/jtwain.dll")).exists();
if (exists) {
// File or directory exists
System.out.println("Found jtwain.dll");
return mapping.findForward("success");
} else {
// File or directory does not exist
System.out.println("Not Found jtwain.dll");
request.getSession().setAttribute("winDir","C:/WINDOWS");
return mapping.findForward("fail");
}



i wrote this one in action class..... i deployed the struts program in weblogic in linux OS...... While executing the application from server i got only linux machine system properties.... I want client side system properties...... whoever open my website i should get their system properties...... so that if they dont have the corresponding dll file...i will ask them to install it in c:\windows directory.... Pleas help me how to check the file found or not in client side.

-Rodricks
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Action class is part of struts framework and will be executed in the server side. So its obvious that you will get the properties of the server machine , now the client machine.

Though I have not worked on applets , but I think applet would be the choice if you want to do something like this as the applet bytecodes will get executed on the client side , not on the server.
Rodricks george
Ranch Hand

Joined: Sep 10, 2006
Posts: 97
Dear Rahul Sir,

As you said i created a J applet Program and got the client details and got the user.home information and checked the windows folder and i redirected to a jsp from applet and the program is successfully running... Thank you sir for really perfect information at rite time...

-Rodricks
 
jQuery in Action, 2nd edition
 
subject: Check the file/found or not
 
Similar Threads
pvcs
How to check file is in use.
filereader
Struts and WTE 4.0
Exception in thread "main" org.springframework.beans.factory.BeanCreationException