aspose file tools*
The moose likes Java in General and the fly likes how to check whether a file exits in a server or not ? 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 check whether a file exits in a server or not ?" Watch "how to check whether a file exits in a server or not ?" New topic
Author

how to check whether a file exits in a server or not ?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 682

suppose i m connected with the server (a client server thing )
can i check whether a file exit in a server or not
but with file.exits() i guess it only works with current system
so how to do this , i know there must be something in java for the same ?


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
How are you connecting to the server? Which protocol?
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 682

Tim Moores wrote:How are you connecting to the server? Which protocol?

suppose there is an application running on a remote desktop which has a server code which keep his port 6000 open for all his client to connect to the server, so i will make a code to connect on that port but, what next , how could i figure out whether this particular file exits on the server or not (its not a hacking thing , so dont misunderstand me)
is there any way ? huh
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Ok, now we know that the remote machine is listening on port 6000. What we still don't know is what kind of server is listening on port 6000. What protocol does it understand? FTP? HTTP? WebDAV? Something else? None of the above? Just because the firewall allows incoming connections on a port does not mean that there is a process listening on that port.
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 682

Tim Moores wrote:Ok, now we know that the remote machine is listening on port 6000. What we still don't know is what kind of server is listening on port 6000. What protocol does it understand? FTP? HTTP? WebDAV? Something else? None of the above? Just because the firewall allows incoming connections on a port does not mean that there is a process listening on that port.

i m doing this for the first time ..but lets see
suppose i have written a program to connect to the server and i will execute it in my machine so , the code will connect to the server because port 6000 is open ..ok
so can i write instruction in that code to check if that server has a file or not ...is this thing possible

2nd option is through any 3rd party ftp connection app that will connect me to the server and i can browse the files but i dont want this option

all i want to write code that performs that operation i need ....so to perform that i need to connect to the server i will do that in a sec but what later can i write code to perform file check from client to that server is this possible ?

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
The client can't do anything to check for the file directly. The server process listening on port 6000 needs to do that; if it's written in Java it can use all the classes in the java.io package for file I/O.

It sounds a bit as if you're not quite clear on how client/server computing works, so again: there needs to be a process that's listening on port 6000, and that performs whatever operations you intend to be done. If there is no such process, then there's nothing the client can do about that.

It would probably be a good idea to work through the Java Tutorial on socket communication: http://download.oracle.com/javase/tutorial/networking/sockets/index.html It includes a fully-functional pair of client and server apps.
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 682

Tim Moores wrote:The client can't do anything to check for the file directly. The server process listening on port 6000 needs to do that; if it's written in Java it can use all the classes in the java.io package for file I/O.

It sounds a bit as if you're not quite clear on how client/server computing works, so again: there needs to be a process that's listening on port 6000, and that performs whatever operations you intend to be done. If there is no such process, then there's nothing the client can do about that.

It would probably be a good idea to work through the Java Tutorial on socket communication: http://download.oracle.com/javase/tutorial/networking/sockets/index.html It includes a fully-functional pair of client and server apps.
i understand a bit of your answer ....what you are saying is that i need to send some instruction to the server process so that it can check whether the file it receive is available in server or not ?....(and yes server is written in java)
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Correct. You'll need to design some simple protocol that client and server can use to communicate; something like the "KnockKnockProtocol" in that example. Be sure to address authentication, so that not just any client can connect, but only authorized ones.
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 682

Tim Moores wrote:Correct. You'll need to design some simple protocol that client and server can use to communicate; something like the "KnockKnockProtocol" in that example. Be sure to address authentication, so that not just any client can connect, but only authorized ones.

k fine i have finally got this functionality up
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to check whether a file exits in a server or not ?
 
Similar Threads
A basic problem
getting error ORA-125 : TNS :no listener while try to login toad
how to debug in netbeans IDE
How to check server is up ?
Which Jar to include for InternalResourceView and JstlView classes?