Тёмный

Java Socket Programming - Send and Download Files Between Client and Server 

WittCode
Подписаться 14 тыс.
Просмотров 52 тыс.
50% 1

In this video we will be using Java sockets and Java Swing to create a GUI that can send and download files between a client and server. In other words, this is a file transfer program. Furthermore, the files that are sent can be previewed before being downloaded. This functionality could be great to add to a Java client server messenger application.
👩‍💻 Download Code 👨‍💻
wittcode.com
🛜 Download My Chrome Extension 🛜
chromewebstore.google.com/det...
💻 Compare Laptop Specs 💻
laptopspectable.com
🔴 Rare Pokemon Cards ⚪️
rarepokemoncards.com
👻 90s Nostalgia 👻
goosebumpsforsale.com

Опубликовано:

 

14 мар 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 175   
@aptechka7353
@aptechka7353 Год назад
зашёл глянуть,как передавать файлы,а тут в начале показывается про постройку внешнего вида приложения и это очень помогло понять JFrame в создании внешнего вида.Всё очень круто!!)И на твой код приятно смотреть)
@kiyimbafahad6169
@kiyimbafahad6169 20 дней назад
Your content will always stand out! The way you concisely and precisely describe each step....❤🎉
@sorendominikkruck5142
@sorendominikkruck5142 3 года назад
Thank you very much for your tutorial. I searched for a way sending data from an Android device to a raspberry pi and the way using a java socket was the only one that worked for me. I searched a few days through the internet and other ways in java didn't worked for me. I am so happy that i've found you.
@WittCode
@WittCode 3 года назад
Hey Sören! That's great to hear! Thank you for the kind words!
@nixer8605
@nixer8605 3 года назад
i saw some guy i comments asked you to make this video and you did...you are amazing....
@WittCode
@WittCode 3 года назад
Thanks for the kind words! I also thought it was a very cool thing to make haha
@mohawberel
@mohawberel 2 года назад
I love ur hints over the video. u made a great work!
@DominikEnder
@DominikEnder 2 года назад
This guy just saved my lazy student ass! Greets from Austria!
@jatinrathi9631
@jatinrathi9631 3 года назад
randomly land to your channel and Loving it!! ......easy to understand ........ you don't only write code but expaint that too . Thankyou ......keep uploading .... 😍
@WittCode
@WittCode 3 года назад
Great to hearJatin! Thanks so much for the support! 😁
@martingogaming1777
@martingogaming1777 2 года назад
Thanks it helped me a lot, I am not really using java sockets, but instead using netty, but sending logic is the same, so thanks for help!
@vedikapainjane3591
@vedikapainjane3591 2 года назад
Thank You! This helped me a lot, very easy to understand
@DassVeryGood
@DassVeryGood 2 года назад
Man’s saving lives out here. Thank you so much, I thought I was done in for this assignment until I found this video!
@phanhuy5350
@phanhuy5350 Год назад
yes sir
@moghenryV
@moghenryV 2 года назад
bro, that's an amazing program to study from. Thanks a lot!
@perronegro4077
@perronegro4077 2 года назад
You are amazing, thank you from Latin America !!!
@guymichelngabonziza6493
@guymichelngabonziza6493 3 года назад
Vraiment c'est du bon boulot. Je parles français, mais j'ai tous compris. Thank you very much sir.
@WittCode
@WittCode 3 года назад
That's great to hear! Thanks for watching 🤠
@KevinGonzalez-sn2mq
@KevinGonzalez-sn2mq 2 года назад
This Guy is saving Litteral Lives
@JohnSmith-ej1qv
@JohnSmith-ej1qv 3 года назад
Thanks man I needed this for class but a little less complicated lol
@WittCode
@WittCode 3 года назад
Hey John! As long as it works 🤠
@cursedtrousers8735
@cursedtrousers8735 3 года назад
What is with the smiley face at the end lol! Awesome content though man
@WittCode
@WittCode 3 года назад
Hey Cursed Trousers 👖👖! It was because I had a green screen issue lol I though it was honestly kind of creepy but I kept it haha
@cellodabest
@cellodabest 3 года назад
You are the GOAT, great video, definitely subscribing
@WittCode
@WittCode 3 года назад
Thanks so much! Welcome to the WittCode family haha 😃
@lanzph1269
@lanzph1269 3 года назад
Thanks For This wittcode!
@WittCode
@WittCode 3 года назад
Anytime Lanz! Thanks for watching!
@respawnlel
@respawnlel 2 года назад
Thanks for the content man.. Expecting more.
@WittCode
@WittCode 2 года назад
Thanks Khandaker! There are certainly more of these videos to come! 😀
@shia6816
@shia6816 3 года назад
you are my saver ! Thanks man ! Waiting for your new video about Java
@WittCode
@WittCode 3 года назад
Hey Shia! Anytime! I'm trying to get a new video out next week on Java 😀
@shia6816
@shia6816 3 года назад
@@WittCode cool ! I learned a lot about java (especial socket) from your video . Cant waiting to watch it
@mohitpandey148
@mohitpandey148 3 года назад
Sir hats off to you.... plz make more java videos and improve my knowledge as a developer
@WittCode
@WittCode 3 года назад
Thanks Mohit! I will definitely be making more Java videos! 😃
@pandaku1046
@pandaku1046 2 года назад
i could find the code for java server client chat but couldnt find the one for file sharing in your website could you help me out?
@betzalel8364
@betzalel8364 8 месяцев назад
⁠@WittCode do you have any videos on how to implement a gremlin function in a Java client script, that will allow the probability of damaged packets to be input as an argument when the program is executed?
@fluffyboy
@fluffyboy Год назад
Good video dude, really interesting, I made it and works perfectly as it shoud thanks a lot.❤
@alperendagistan2846
@alperendagistan2846 Год назад
Can you share your codei please? Because I wrote Server and Client code and when i try to send a file from client to server. I couldn't see my file on the server receiver list. Thanks.
@arturomtz921
@arturomtz921 3 года назад
Thanks man, it really helped me a lot.
@WittCode
@WittCode 3 года назад
Anytime! Thank you for watching! 😀
@bertievisick9889
@bertievisick9889 3 года назад
Wittcode coming in clutch......thanks boss
@WittCode
@WittCode 3 года назад
Anytime Bertie! Thanks for stampeding the like button! 🦖
@amc1140
@amc1140 2 года назад
Any advice on not seeing 40 ads in this video? Jk get that money bro. Great explaination, it was super helpful!
@nishattabassum819
@nishattabassum819 2 года назад
Can I also share pdf file and download it instead of text or png file, using this method?
@khadijamostudio
@khadijamostudio Год назад
Thank you for the awesome tutorial! I followed everything you did and double checked using your GitHub code. However, whenever I click on "Yes" for downloading, the file doesn't download on my server :/ can you please help?
@3dportableinc64
@3dportableinc64 2 года назад
thank you, very helpful.
@Hassan-mona
@Hassan-mona 2 года назад
if i want to send files from server to clients what should i modify
@dillondonovan9074
@dillondonovan9074 3 года назад
Great video!
@WittCode
@WittCode 3 года назад
Great to hear Dillon! Thanks for watching! 🤠
@arulkumara2077
@arulkumara2077 3 года назад
Very useful Thank you so much
@WittCode
@WittCode 3 года назад
Anytime Arul! Thanks for watching! 😃
@akeidz
@akeidz 3 года назад
Very helpful! Subscribed and liked :)
@WittCode
@WittCode 3 года назад
Great to hear Ahmad! Glad it helped! 😃
@akeidz
@akeidz 3 года назад
@@WittCode Just one question at, 40:00 what if I want to send other files extension like pdf, pptx. Does it work the same as the one you code for txt?
@WittCode
@WittCode 3 года назад
@@akeidz Hey Ahmad good to hear from you again! So this program should be able to send any type of file over including pdf and pptx but it can only preview the content of text and images. So you can send over a pdf but not display the content of it. Though I dont think that would be too hard to implement!
@akeidz
@akeidz 3 года назад
@@WittCode Ah I see, I might have missed that part lol Thanks a lot mister WittCode!
@kresimirsumiga1584
@kresimirsumiga1584 Год назад
How to transfer complex objects, lets say color of a circle?
@leylitarab3
@leylitarab3 2 года назад
Thank you so much bro 👏👏
@WittCode
@WittCode 2 года назад
Anytime man! Thanks so much for watching! 😀
@rxkshan
@rxkshan 3 года назад
cool bro plz make videos on android game dev and webdev
@shamsakanwal2182
@shamsakanwal2182 2 года назад
Can u plz share these two files:client and server?
@theodoroskapsalis5232
@theodoroskapsalis5232 2 года назад
The code is missing from your website can you please provide the code????
@prometheusli101
@prometheusli101 3 года назад
excellent tutorial
@WittCode
@WittCode 3 года назад
That's always great to hear! Thanks for watching 🤠
@fitree4482
@fitree4482 Год назад
Hi WittCode thank you so much for your easy to understand explanation! But I'm having an issue where I try to send file to the server but nothing happen. Do you know why this is happening?
@himanshutripathi7272
@himanshutripathi7272 11 месяцев назад
Same issue... Did you find the solution yet??
@junioradi6554
@junioradi6554 2 года назад
Nice !
@amindendani6823
@amindendani6823 Год назад
When I click on the file in the server Fram Nothing happened
@aiml5910
@aiml5910 10 месяцев назад
Hey how to transfer folders?
@ArunKumar-gp2vq
@ArunKumar-gp2vq 2 года назад
What if I wanted to maintain a record of file being shared like at what time and etc? How will this be done? Thanks
@WittCode
@WittCode 2 года назад
Hey Arun! I would use the Java date class and after a file is sent just have a method that records the time and then saves it somewhere.
@RobvanBode
@RobvanBode 4 месяца назад
Code no longer available?
@user-nx9zf3qk7x
@user-nx9zf3qk7x Год назад
Where is the code i don't founded when get to download it
@binjabdu
@binjabdu 2 года назад
gold video !
@huzaifa6466
@huzaifa6466 28 дней назад
Can't find it on ur website 😢
@user-pn9vy3tu5q
@user-pn9vy3tu5q 8 месяцев назад
code is not available in your website
@ehabwa1167
@ehabwa1167 2 года назад
Thnx for this amazing video YOU ARE PERFECT 👌 But when I run the client project The labels don't appear ? Please i need your help
@yomiyoubelay1789
@yomiyoubelay1789 2 года назад
would you please upload the source code for this program
@Ipoyu
@Ipoyu Год назад
you saved my family from extinction
@thesos4643
@thesos4643 2 года назад
hey great video thanks a lot, but i have a problem , it works fine on my pc, but when i send from another it dosent complete and the readfully keeps waiting and not recieving, every other function i have works so the other pc is for sure connected to the socket but it dosent read all bytes
@thesos4643
@thesos4643 2 года назад
The readInt is receiving a different value from the writeInt in the client and idk why :(
@MikeThr33
@MikeThr33 Год назад
Cybersecurity left the chat. Besides that really cool tutorial.
@l4vos99
@l4vos99 3 года назад
What changes do I need to make to send multiple files?
@WittCode
@WittCode 3 года назад
Hey there! You can send as many files as you want! No changes needed 🤠
@gersonsoccarobuis3910
@gersonsoccarobuis3910 2 года назад
nice!
@parthshah4664
@parthshah4664 3 года назад
Hey I have school project due in few hours relared to java socket and was wondering if you have any suggestions on how to send and receive objects through arbitrary data
@WittCode
@WittCode 3 года назад
Hey Parth sorry for the late response! I haven't looked into sending objects yet but that could be a new video! I would do what I did in this video and convert each of the objects properties to byte arrays and send them to the server and recreate the object there! There might be another way but I haven't looked into it too much yet! Hope this helps 🤠
@parthshah4664
@parthshah4664 3 года назад
@@WittCode thank you
@arslanmir8833
@arslanmir8833 2 месяца назад
I can't find the code
@deema3861
@deema3861 2 года назад
Thanks for your helpful videos, I wonder if there is a way to contact you, I want to ask some important questions if you don't mind
@seifeldienahmed820
@seifeldienahmed820 Год назад
you saved my ass dude :)
@ashul2551
@ashul2551 2 года назад
Its posible to dont choose the file and send a specific file every time u execute it ?
@WittCode
@WittCode 2 года назад
Hey there! Yes you can! Instead of doing the JOptionPane just have create a File object from the file you want to send and send that over!
@charbelchammai845
@charbelchammai845 3 года назад
Excuse me i am having a little problem i hope you can help me with it, i want to try and run this server from a button from my application for a uni project, when i tried running it with the Server.main(new String[0]); it freezes and the whole IDE stops working, so i thought i would try and run it using threads, i did it but the application does not seem to run, i would really appreciate any help. thank you in advance
@WittCode
@WittCode 3 года назад
Hey Charbel! What do you mean by run this server from a button? You mean you press a button on a GUI and the server starts? In this example the server is up and running when the application starts.
@DimitrisTsoykalas
@DimitrisTsoykalas 2 года назад
you need onother thread....
@alirazasharafat9351
@alirazasharafat9351 2 года назад
Thanks for this video. Please can you send us the code of this video?
@jacobchammai3704
@jacobchammai3704 3 года назад
excuse me but can this code be used to send data over devices connected on the same local host? or what is the purpose of it otherwise?
@WittCode
@WittCode 3 года назад
Hey Jacob! Yes you can use other devices you just have to provide the right connection details to the socket object! The client uses localhost because the server is on the same computer. If you were using another computer you need to specify the IP address of the server! It won't be localhost! Hope this helps!
@jacobchammai3704
@jacobchammai3704 3 года назад
@@WittCode so if the client was another device, i would have to specify the private IP address of the pc that the server is open on right?
@WittCode
@WittCode 3 года назад
@@jacobchammai3704 that is correct! A socket object is IP address and port number to communicate on! So supply the port number the server is listening on and it's IP address!
@kristanbottjer8001
@kristanbottjer8001 3 года назад
does this still work if you put the server and cient int the same project but diffrent packages?
@WittCode
@WittCode 3 года назад
Hey Kristan! That's an interesting question! I believe you could by running them with separate threads? So implement the runnable interface to the server class and set it up and run it in the overriden run() method. And then run the client as is. Or vice versa. There might be other ways but I'm not entirely sure. Hope this helps!
@kristanbottjer8001
@kristanbottjer8001 3 года назад
@@WittCode it does work however with an inconvenience. it does not save the files or pic's.
@WittCode
@WittCode 3 года назад
@@kristanbottjer8001 it doesn't save the files when you use another thread? It does when you run it normally though right?
@arslanmir8833
@arslanmir8833 2 месяца назад
it's an amazing video . THanks a lot you saved my lazy student ass , but I can't find the code in your website.
@muh.redhoarifrahman3586
@muh.redhoarifrahman3586 3 года назад
good bro
@WittCode
@WittCode 3 года назад
Thanks for the kind words! 🤓
@mdgeek99
@mdgeek99 Год назад
I couldn't download the code bro😓
@nachwakraiem1572
@nachwakraiem1572 2 года назад
thank you very much it's great video . but if you can help me i want send and download files between multi clients and server !! you are amazing .
@WittCode
@WittCode 2 года назад
Hey Nachwa! That is definitely a video for the future! 😀It will be the same thing but with multiple threads to handle multiple clients.
@andyvuitton5559
@andyvuitton5559 Год назад
i have done everything correctly except for the server code . someone please help
@andyvuitton5559
@andyvuitton5559 Год назад
nevermind i got it
@MonsieurDOjo
@MonsieurDOjo 3 года назад
yes can we put a chat within?
@WittCode
@WittCode 3 года назад
Hey there! You most certainly can! However this wouldnt be an easy addition. I'll be making a video on a messenger like that in the future 🤠
@bhanuduhan9765
@bhanuduhan9765 2 года назад
i am facing ana error C:\Users\PC\IdeaProjects\client bhanu\src\client3.java:9:8 java: class Client is public, should be declared in a file named Client.java
@WittCode
@WittCode 2 года назад
Hey there! It seems like you created a class called Client in a file where the name is not Client.java? It seems like you might have named it Client3.java. Make sure the name of the class and file match!
@bhanuduhan9765
@bhanuduhan9765 2 года назад
I have one more issue can we open file directly means when the file recive at server side it get open automatically
@khaoula2359
@khaoula2359 2 года назад
where is the code ???????????
@piyushkesharwani1987
@piyushkesharwani1987 3 года назад
Is this necessary to connect devices to same network ?
@WittCode
@WittCode 3 года назад
Hey Piyush! They do not need to be on the same network but you need the right connection information. You just have to pass this into the Socket constructor. 😃
@piyushkesharwani1987
@piyushkesharwani1987 3 года назад
Ok. But I am getting connection timed out error when trying to send the file to another devices. Can you help me with that ?
@WittCode
@WittCode 3 года назад
@@piyushkesharwani1987 Does the server that you are connecting to have a Public IP address or a private one?
@piyushkesharwani1987
@piyushkesharwani1987 3 года назад
@@WittCode Its my friend's PC
@WittCode
@WittCode 3 года назад
@@piyushkesharwani1987 I'm guessing your friends computer is on a private network so the router will have a public address but your friends computer will most likely be private. I am not sure how to work around this but if I do I'll let you know 🤠
@kumak9890
@kumak9890 3 года назад
Can we create the booking system using this socket programming?
@WittCode
@WittCode 3 года назад
Hey there! Sorry but can you explain the booking system to me or give me more details?
@kumak9890
@kumak9890 3 года назад
@@WittCode for example, i like to create a reservation system for hotel. So the server will calculate the price arh sent back to the client, and the client can download the receipt.. That's what I think.. Thanks WittCode
@WittCode
@WittCode 3 года назад
@@kumak9890 This could definitely be made this way! Im not sure if it is the best way but you could get the values from the client and parse them and then create a file on the server with the calculated values and send it back to the user just like in this video! Maybe an email would be better for something like this?
@kumak9890
@kumak9890 3 года назад
@@WittCode exactly..Can you explain the about the Email? Not fully understand 😅
@WittCode
@WittCode 3 года назад
@@kumak9890 No worries! I'll actually be making a video on how to send an email with Java at some point so that'll probably explain it best. But I would say when you get a purchase from the client parse the values and send an email receipt?
@DimitrisTsoykalas
@DimitrisTsoykalas 2 года назад
Someone is deleting my comments?....or its yt faulty?
@ddh6559
@ddh6559 3 года назад
can you change from localhost to public
@WittCode
@WittCode 2 года назад
Hey there! You can! With a socket connection you just need to provide the correct port number and IP address that you want to connect to. So you would use the target IP address as opposed to 'localhost' in the socket constructor.
@DimitrisTsoykalas
@DimitrisTsoykalas 2 года назад
@@WittCode but how we can open the address?..i just made the question one more time in some comment but put it also here in case you have time and you want to help...
@Rockstar04099
@Rockstar04099 10 месяцев назад
Please send me the code
@KamrulIslam-ke9jh
@KamrulIslam-ke9jh 2 года назад
Is this UDP or TCP ? Please let me know
@WittCode
@WittCode 2 года назад
Hey Kamrul! This project uses Java sockets which implement TCP. So the file contents should be arriving in order and checks should be in place.
@KamrulIslam-ke9jh
@KamrulIslam-ke9jh 2 года назад
Thanks a lot Brother. Best wishes to you.
@KamrulIslam-ke9jh
@KamrulIslam-ke9jh 2 года назад
Is there ftp protocol to transfer the file ?
@rxkshan
@rxkshan 3 года назад
wittcode please give the sourcecode of this Java Socket Programming - Send and Download Files Between Client and Server
@WittCode
@WittCode 3 года назад
Hey man! Yeah I'm gonna upload it to my GitHub today so I'll post the link in the description!
@rxkshan
@rxkshan 3 года назад
You are cool man
@rxkshan
@rxkshan 3 года назад
@@WittCode plzz do it
@WittCode
@WittCode 3 года назад
Hey dude sorry I forgot about this! I'll get it to today and send the link to you here 🤓
@rxkshan
@rxkshan 3 года назад
@@WittCode thanku but fast wittcode!
@IXIIMI
@IXIIMI Год назад
Hi WittCode thank you so much for your easy to understand explanation! But I'm having an issue where I try to send file to the server but nothing show up in the Server Jframe. Here is the link of the code that I have done: docs.google.com/document/d/19OFc0GoOcXTWs7APUwvJAHf1wJJK4tKPp9eZq_vPMrc/edit?usp=sharing. BTW, What IDE are you using? Can you give me a download link?
@9911476524
@9911476524 6 месяцев назад
Can we send file of a particular ip address instead of local host
@RazanAlFaisal
@RazanAlFaisal Год назад
would you please upload the source code for this program
Далее
Java Socket Programming - Multiple Clients Chat
40:18
Просмотров 176 тыс.
File Transfer via Sockets in Python
14:44
Просмотров 57 тыс.
Я ПОКУПАЮ НОВУЮ ТАЧКУ - МЕЧТУ!
39:05
Java UDP Client Server Messenger
22:14
Просмотров 22 тыс.
Java Socket Programming Client Server Messenger
16:28
Просмотров 100 тыс.
File transfer program in java using TCP made Simple
9:31
Java - How to Send an Email with Attachments
17:53
Просмотров 13 тыс.
JavaFX and Java Sockets - Client Server Messenger
53:59
How to Compile Java Programs into EXEs
23:32
Просмотров 28 тыс.
Java Collections Framework | Full Course ✅
3:25:12
Просмотров 348 тыс.
Simple FTP Server in Python
12:13
Просмотров 22 тыс.
Indroduction to Java NIO and non-blocking sockets
31:47