0

Having done a bit of searching/researching and not finding an answer, I turn to you all.

I want to read a specific file that resides in a specific directory using a socket from the client side. I am able to establish the connection with no problem but am unsure as to how to set-up a read for a specific file.

for example... filea.txt resides in directory called directoryA on serverX. How can fileA be read from serverY using a socket? Do I create a wrapper for socket.getInputStream to read that specific file? Is there a way to direct the connection to that specific directory?

Looking at the javadoc for the socket class, I do not see how to accomplish what I want to do with that.

Any information you can provide to lead me in the right direction is appreciated.

Thanks.

Thomas Grady
  • 752
  • 2
  • 11
  • 22
  • 1
    You can not just grab the file from the remote computer by executing some client code. The server needs to actually **serve** this data on a certain socket. Or did I misunderstood you, and you are actually talking about getting the file contents via a HTTP server? – bosnjak Mar 14 '14 at 13:25
  • 1
    Do you mean that you have no idea to get a file via the socket?? If yes, you can check this http://stackoverflow.com/questions/13555668/java-send-file-using-sockets. Or you mean something else?? – Engine Bai Mar 14 '14 at 13:36
  • @Lawrence, thanks for clearing that up for me. I was not thinking I had to have a server side provide the file for the client side to read. – Thomas Grady Mar 14 '14 at 13:44
  • @Engine... I understand how to read a file, my challange was to read a specific file from a particular location. Thanks for providing the link - that and Lawrence's response give me what I am looking for. – Thomas Grady Mar 14 '14 at 13:45

0 Answers0