Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java transfer file over socket

Socket socket =  new Socket() ; //Open a socket with the server
OutputSteam opt = socket.getOutputStream ; // get the outputStream of the socket 
// so we can write in it 
File file = new File(" Path of the file you want to send ") ; 
FileInputStream fis = new FileInputeStream(file) ; 

byte[] data = new byte[ 1024 * 16 ] ;
int count  ; 
while( (count  = fis.read(data))  > 0){
  opt.write(data , 0 , count) ; 
}
Source by www.instagram.com #
 
PREVIOUS NEXT
Tagged: #java #transfer #file #socket
ADD COMMENT
Topic
Name
5+8 =