File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Send a file across the network

 
dushantha Rathnayake
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an client server application. in some cases I want to send files between server and client. But I don't know how to do it. Can I do it using socket programming? the files that I want to send can be documents, media files, text files, pdf files, ect.... . Actually I want to send a file across the network. please help me.

thank you.
 
Richard Golebiowski
Ranch Hand
Posts: 213
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could send it using FTP.
 
Lester Burnham
Rancher
Posts: 1337
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sockets would work, and might be the fastest way to getting this implemented if the requirements are simple. Or you could use an embedded Java FTP server like http://mina.apache.org/ftpserver/ and a client like http://commons.apache.org/net/
 
dushantha Rathnayake
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My application is not a web application. I need to implement this file sending on a LAN. If I can use socket programming to do this, then how can I do it? If you have an example code please post it or if you can give me a link please post them. I am new for this socket programming side. Please help me.

Thank you.
 
Lester Burnham
Rancher
Posts: 1337
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Searching for "java socket tutorial" should find the relevant chapter of the Sun Java Tutorial. It contains an example of a pair of standalone client/server applications that communicate via sockets.
 
Richard Golebiowski
Ranch Hand
Posts: 213
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dushantha Rathnayake wrote:Hi,

My application is not a web application. I need to implement this file sending on a LAN. If I can use socket programming to do this, then how can I do it? If you have an example code please post it or if you can give me a link please post them. I am new for this socket programming side. Please help me.

Thank you.


It doesn't matter if it's a web application. As long as the network is TCP, you can use a FTP server and client as was suggested. For a project, I wrote a DOS FTP server in Java and a DOS client in Pascal that was used to replace file transfer vis modem in an application. The client was not a web application.
 
Andrey Kozhanov
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Below is a very basic sample of using sockets for transfering files of any type over the network, but it could give you general idea. Output file is written to current server working directory and no additional checking is provided. So if file of the same name already exists, it would be overwritten.

Server.java


and Client.java
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic