java - keeping the file name after file transfer -


i'm working on p2p file transfer via socket on java, , i've managed source file(image,pdf,txt,etc) sent other directory on localhost. problem if there way keep file name of copy same original file name after transfer without hardcoding (i'm using argument line source file path, assign port connect to, ip of target connection, , output path)

you have sent through socket connection. see 2 solution:

first solution: send through new connection.

  • open connection, send file name, close it.
  • open connection, send file data, close it.
  • save file name , data received.

second solution: send name through same connection.

  • open connection, send file name special final byte. on client side read bytes until find special byte.
  • still in client side continue read bytes , save in new file.

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -