Can't send large files over socket in Java

前端 未结 5 1636
执念已碎
执念已碎 2021-01-14 06:51

I got working server and client applications, they work perfect while sending small files, but when I try to send for example movie file that is 700mb over socket it gives m

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-14 07:15

    It gives you OutOfMemoryError because you are trying to read the entire file into memory before sending it. This is 100% completely and utterly unnecessary. Just read and write chunks, much as you are doing in the receiving code.

提交回复
热议问题