• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to download files from a remote server via java code?

 
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
finally now i m capable of finding out whether a particular file exits in a remote server or not ..so if i know that
this particular file exits in a remote server what can i do to download that file in my machine ..so for that i need options
like
  • 1 there should be something in java api to download a file from a particular url or absolute path


  • note : both client & server are written in java .
     
    Saloon Keeper
    Posts: 7585
    176
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    This seems like the same problem we talked about at https://coderanch.com/t/556511/java/java/check-whether-file-exits-server, isn't it? So the question is still the same: what protocol does the server understand? For commonly used file transfer protocols like FTP, HTTP, WebDAV and CIFS it's easy to find Java servers. If, OTOH, you're set on implementing your own protocol then you need to write both client and server code for that.
     
    naved momin
    Ranch Hand
    Posts: 692
    Eclipse IDE Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Tim Moores wrote:This seems like the same problem we talked about at https://coderanch.com/t/556511/java/java/check-whether-file-exits-server, isn't it? So the question is still the same: For commonly used file transfer protocols like FTP, HTTP, WebDAV and CIFS it's easy to find Java servers. If, OTOH, .


    this is not the same like earlier there i just need to check but here i need to download that file too

    what protocol does the server understand?


    i guess windows pc can transfer file using both ftp & http (ya you are right server running on windows machine)

    you're set on implementing your own protocol then you need to write both client and server code for that



    ya this sounds nice to me (because i guess you are not understanding my problem or what i want to achieve ) here i need to implement a code that does
    every thing first check and then download to my machine
    1st work is done but i need to figure out a way to download a file from server
    so i need to give functionality to the server to check for a file and if exits then send that file to the client (not name but the file itself) i know this is achieve through ftp or http but is there any way in java so that i can download the file from the server
    hope you got it
    if not please ask me again



     
    author
    Posts: 23951
    142
    jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    naved momin wrote:

    Tim Moores wrote:This seems like the same problem we talked about at https://coderanch.com/t/556511/java/java/check-whether-file-exits-server, isn't it? So the question is still the same: For commonly used file transfer protocols like FTP, HTTP, WebDAV and CIFS it's easy to find Java servers. If, OTOH, .


    this is not the same like earlier there i just need to check but here i need to download that file too



    The question may be different, but the answer is the same. The other answer was, the server application must do it (check on the file) and then inform the client. This answer is, the server application must do it (check on the file, open the file, and get the data), and then inform the client (the two applications need a protocol to send the data).

    Henry
     
    Henry Wong
    author
    Posts: 23951
    142
    jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    naved momin wrote:

    Tim Moores wrote:what protocol does the server understand?


    i guess windows pc can transfer file using both ftp & http (ya you are right server running on windows machine)




    Don't guess. Check it. By default, Windows don't do expose file transfer, unless it is configured. And in some cases, you need to install a third party service.

    Keep in mind, we are talking about the server here. Just because you can run a client that supports ftp and http, doesn't mean that there is a service that will support that protocol when another client tries to connect.

    Henry
     
    naved momin
    Ranch Hand
    Posts: 692
    Eclipse IDE Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Henry Wong wrote:

    naved momin wrote:

    Tim Moores wrote:what protocol does the server understand?


    i guess windows pc can transfer file using both ftp & http (ya you are right server running on windows machine)




    Don't guess. Check it. By default, Windows don't do expose file transfer, unless it is configured. And in some cases, you need to install a third party service.

    Keep in mind, we are talking about the server here. Just because you can run a client that supports ftp and http, doesn't mean that there is a service that will support that protocol when another client tries to connect.

    Henry


    ok i need a protocol to send the information from the server to the client
  • 1 so can we make a ftp protocol in java ..if yes then give me some ideas like first do this or do that etc etc


  • 2 if no ..what should be mine next option to achieve this ?
  •  
    Tim Moores
    Saloon Keeper
    Posts: 7585
    176
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I'm not quite sure what you mean by "can we make a ftp protocol in java" - protocols are independent of particular languages. Both FTP client and server implementations are available for Java. Check out Apache Commons Net for the client side, and the Apache Mina FTP server.
     
    naved momin
    Ranch Hand
    Posts: 692
    Eclipse IDE Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Tim Moores wrote:I'm not quite sure what you mean by "can we make a ftp protocol in java" - protocols are independent of particular languages. Both FTP client and server implementations are available for Java. Check out Apache Commons Net for the client side, and the Apache Mina FTP server.



    ok now i have a new way
    when i will send some request to the server the server will open up the ftp.exe program in the system32 folder so what after this step
    there is a command to open a connection between client and server whose syntax is
    but the problem is how i can write that command in a ftp program via code ?? if you can solve my this problem rest i will manage all i am sure this thing will work for sure
     
    Sheriff
    Posts: 22783
    131
    Eclipse IDE Spring VI Editor Chrome Java Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Use an FTP library instead. Apache Commons Net has an FTP client, and I personally use JvFTP whenever I need to access an FTP server from Java.
     
    naved momin
    Ranch Hand
    Posts: 692
    Eclipse IDE Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Rob Spoor wrote:Use an FTP library instead. Apache Commons Net has an FTP client, and I personally use JvFTP whenever I need to access an FTP server from Java.



    there are plenty of codes written to download a file using Url class but they say this method is not guarenteed to be working for any kind of ftp server ...what does that means
    if my ftp server is filezilla server cant i use URL class to connect to it and use some logic to get the file will this work ?
    or i should go with the JvFTP you suggested but i dont know how to use it
     
    reply
      Bookmark Topic Watch Topic
    • New Topic